Manually setting PORT for Docker Image

I'm running a docker image (kong) that listens on 8000 by default. As it doesn't use PORT, I have manually added PORT=8000 as a variable (which is mentioned as an alternative in Fixing Common Errors [0] ). When I make a request via public url, I get "Application failed to respond". When I run the same image locally, I can make request to 8000 without an issue, so I'm not sure could have gone wrong. I would appreciate any help! [0] https://docs.railway.app/troubleshoot/fixing-common-errors#application-error-this-application-failed-to-respond
Railway Docs
Fixing Common Errors | Railway Docs
Documentation for Railway
43 Replies
Percy
Percy13mo ago
Project ID: 34a3782b-6485-41f9-923a-6b3b9753ab6e
ChubbyAvocado
ChubbyAvocado13mo ago
project id: 34a3782b-6485-41f9-923a-6b3b9753ab6e
Floris
Floris13mo ago
how is your port defined ? in the docker if you dont need to listen to port8000 then make your kong listen to the env var 'PORT' railway should populate it with their chosen port during deployment
Brody
Brody13mo ago
OP said Kong doesn't use PORT, there is plenty of software that use hardcoded ports, so settings a PORT variable to the same port the software listens on works too @ChubbyAvocado will need more info though, is port 8000 running an http server?
ChubbyAvocado
ChubbyAvocado13mo ago
Yes, it’s an api gateway so it mainly just routes to other http services. Locally I don’t have any issue making http requests to 8000 but something seems messed up with the deployment on railway 😔
Brody
Brody13mo ago
okay then it also needs to be listening on the host 0.0.0.0, Kong probably has some way to configure the host it listens on look into that
ChubbyAvocado
ChubbyAvocado13mo ago
Thanks, I believe the default is 0.0.0.0:8000 (I will double check). https://docs.konghq.com/gateway/latest/reference/configuration/#nginx-section
Kong Docs
Configuration Reference for Kong Gateway - v3.4.x | Kong Docs
Documentation for Kong, the Cloud Connectivity Company for APIs and Microservices.
Brody
Brody13mo ago
there also stuff about SSL and HTTPS, and http2, make sure you only listen on http 1.1 with no SSL of any kind
ChubbyAvocado
ChubbyAvocado13mo ago
As far as I can tell it's http 1.1 only without ssl. 🥲 Any other idea on what else could have gone worng or how to further debug this?
Brody
Brody13mo ago
you have set a PORT service variable to 8000 right?
ChubbyAvocado
ChubbyAvocado13mo ago
yeah!
ChubbyAvocado
ChubbyAvocado13mo ago
No description
Brody
Brody13mo ago
does Kong have a docker image?
ChubbyAvocado
ChubbyAvocado13mo ago
i'm using kong:3.4.2 https://hub.docker.com/_/kong
kong - Official Image | Docker Hub
The Cloud-Native API Gateway for APIs and Microservices
Brody
Brody13mo ago
ill see what i can do kong listens on multiple ports
ChubbyAvocado
ChubbyAvocado13mo ago
right 8000 is for proxy 8001 is admin api 8002 is admin dashboard
Brody
Brody13mo ago
you cant access a railway service publicly from multiple ports
ChubbyAvocado
ChubbyAvocado13mo ago
even if i only need to expose one port?
Brody
Brody13mo ago
if you only care about exposing one port, then it doesnt matter what do you want to expose? the admin gui?
ChubbyAvocado
ChubbyAvocado13mo ago
8000 that's the proxy
Brody
Brody13mo ago
how do you plan on configuring kong if you are exposing the proxy instead of the admin gui
ChubbyAvocado
ChubbyAvocado13mo ago
for now, I can connect to postgres directly (spin up gui locally and connect to railway postgres where kong config is stored). I guess later assuming I can access 8001 internally, the other backend service will send requests to 8001 to control kong.
Brody
Brody13mo ago
their docs suck, send me the page where they list all of the env vars you can use? seriously, these docs sucks https://docs.konghq.com/gateway/latest/production/environment-variables/
ChubbyAvocado
ChubbyAvocado13mo ago
GitHub
kong/kong.conf.default at master · Kong/kong
🦍 The Cloud-Native API Gateway . Contribute to Kong/kong development by creating an account on GitHub.
ChubbyAvocado
ChubbyAvocado13mo ago
yeah lol i also tried to find it once and this is the best i found so far
Brody
Brody13mo ago
those arent env vars though
ChubbyAvocado
ChubbyAvocado13mo ago
my understanding is that these map to env var e.g. proxy_listen -> KONG_PORXY_LISTEN
luna
luna13mo ago
log_level setting -> KONG_LOG_LEVEL env variable
you're missing the KONG prefix
Brody
Brody13mo ago
dumb
luna
luna13mo ago
but yes those should all map over
ChubbyAvocado
ChubbyAvocado13mo ago
@luna oh yeah that's important 🙏
luna
luna13mo ago
if you cant get that one working btw this very likely works with envs https://hub.docker.com/r/bitnami/kong/
ChubbyAvocado
ChubbyAvocado13mo ago
I also tried to make some requests via private network (another railway service) just for debugging purposes and that also didn't work... (calling http://${APP_NAME}.railway.internal:8000 from another service). thanks! I don't think env var is an issue here though (based on debug logs and it also connects to the postgres without an issue)
Brody
Brody13mo ago
that for sure wouldnt work, the proxy listens on 0.0.0.0, and ipv4 address but the private network is ipv6 only
ChubbyAvocado
ChubbyAvocado13mo ago
I see 😦
Brody
Brody13mo ago
neither images are behaving
ERROR: /opt/bitnami/kong/bin/kong:6: module 'kong.globalpatches' not found:
no field package.preload['kong.globalpatches']
no file './kong/globalpatches.lua'
no file './kong/globalpatches/init.lua'
no file '/opt/bitnami/kong/openresty/site/lualib/kong/globalpatches.ljbc'
no file '/usr/local/share/lua/5.1/kong/globalpatches.lua'
no file '/usr/local/share/lua/5.1/kong/globalpatches/init.lua'
no file '/opt/bitnami/kong/openresty/luajit/share/lua/5.1/kong/globalpatches.lua'
no file '/opt/bitnami/kong/openresty/luajit/share/lua/5.1/kong/globalpatches/init.lua'
no file '/opt/bitnami/kong/openresty/site/lualib/kong/globalpatches.so'
no file '/opt/bitnami/kong/openresty/lualib/kong/globalpatches.so'
no file './kong/globalpatches.so'
no file '/usr/local/lib/lua/5.1/kong/globalpatches.so'
no file '/opt/bitnami/kong/openresty/luajit/lib/lua/5.1/kong/globalpatches.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file '/opt/bitnami/kong/openresty/site/lualib/kong.so'
no file '/opt/bitnami/kong/openresty/lualib/kong.so'
no file './kong.so'
no file '/usr/local/lib/lua/5.1/kong.so'
no file '/opt/bitnami/kong/openresty/luajit/lib/lua/5.1/kong.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
/opt/bitnami/kong/bin/kong:6: in function 'file_gen'
init_worker_by_lua:47: in function <init_worker_by_lua:45>
[C]: in function 'xpcall'
init_worker_by_lua:54: in function <init_worker_by_lua:52>
ERROR: /opt/bitnami/kong/bin/kong:6: module 'kong.globalpatches' not found:
no field package.preload['kong.globalpatches']
no file './kong/globalpatches.lua'
no file './kong/globalpatches/init.lua'
no file '/opt/bitnami/kong/openresty/site/lualib/kong/globalpatches.ljbc'
no file '/usr/local/share/lua/5.1/kong/globalpatches.lua'
no file '/usr/local/share/lua/5.1/kong/globalpatches/init.lua'
no file '/opt/bitnami/kong/openresty/luajit/share/lua/5.1/kong/globalpatches.lua'
no file '/opt/bitnami/kong/openresty/luajit/share/lua/5.1/kong/globalpatches/init.lua'
no file '/opt/bitnami/kong/openresty/site/lualib/kong/globalpatches.so'
no file '/opt/bitnami/kong/openresty/lualib/kong/globalpatches.so'
no file './kong/globalpatches.so'
no file '/usr/local/lib/lua/5.1/kong/globalpatches.so'
no file '/opt/bitnami/kong/openresty/luajit/lib/lua/5.1/kong/globalpatches.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file '/opt/bitnami/kong/openresty/site/lualib/kong.so'
no file '/opt/bitnami/kong/openresty/lualib/kong.so'
no file './kong.so'
no file '/usr/local/lib/lua/5.1/kong.so'
no file '/opt/bitnami/kong/openresty/luajit/lib/lua/5.1/kong.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
/opt/bitnami/kong/bin/kong:6: in function 'file_gen'
init_worker_by_lua:47: in function <init_worker_by_lua:45>
[C]: in function 'xpcall'
init_worker_by_lua:54: in function <init_worker_by_lua:52>
i give up
ChubbyAvocado
ChubbyAvocado13mo ago
@Brody Thanks for trying!
Brody
Brody13mo ago
sorry i couldnt solve it
ChubbyAvocado
ChubbyAvocado13mo ago
maybe i will try find an alternative this point lol
Brody
Brody13mo ago
caddy
ChubbyAvocado
ChubbyAvocado13mo ago
I'm not familiar with it. Does it support rate-limting and key authentication? (for third-party access) Those were the main reasons for considering Kong.
Brody
Brody13mo ago
im sure you could yeah https://caddyserver.com/
ChubbyAvocado
ChubbyAvocado13mo ago
cool, I will check it out.
Want results from more Discord servers?
Add your server