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
Percy14mo ago
Project ID: 34a3782b-6485-41f9-923a-6b3b9753ab6e
ChubbyAvocado
ChubbyAvocadoOP14mo ago
project id: 34a3782b-6485-41f9-923a-6b3b9753ab6e
Floris
Floris14mo 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
Brody14mo 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
ChubbyAvocadoOP14mo 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
Brody14mo 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
ChubbyAvocadoOP14mo 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
Brody14mo 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
ChubbyAvocadoOP14mo 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
Brody14mo ago
you have set a PORT service variable to 8000 right?
ChubbyAvocado
ChubbyAvocadoOP14mo ago
yeah!
ChubbyAvocado
ChubbyAvocadoOP14mo ago
No description
Brody
Brody14mo ago
does Kong have a docker image?
ChubbyAvocado
ChubbyAvocadoOP14mo 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
Brody14mo ago
ill see what i can do kong listens on multiple ports
ChubbyAvocado
ChubbyAvocadoOP14mo ago
right 8000 is for proxy 8001 is admin api 8002 is admin dashboard
Brody
Brody14mo ago
you cant access a railway service publicly from multiple ports
ChubbyAvocado
ChubbyAvocadoOP14mo ago
even if i only need to expose one port?
Brody
Brody14mo ago
if you only care about exposing one port, then it doesnt matter what do you want to expose? the admin gui?
ChubbyAvocado
ChubbyAvocadoOP14mo ago
8000 that's the proxy
Brody
Brody14mo ago
how do you plan on configuring kong if you are exposing the proxy instead of the admin gui
ChubbyAvocado
ChubbyAvocadoOP14mo 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
Brody14mo 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
ChubbyAvocadoOP14mo 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
ChubbyAvocadoOP14mo ago
yeah lol i also tried to find it once and this is the best i found so far
Brody
Brody14mo ago
those arent env vars though
ChubbyAvocado
ChubbyAvocadoOP14mo ago
my understanding is that these map to env var e.g. proxy_listen -> KONG_PORXY_LISTEN
luna
luna14mo ago
log_level setting -> KONG_LOG_LEVEL env variable
you're missing the KONG prefix
Brody
Brody14mo ago
dumb
luna
luna14mo ago
but yes those should all map over
ChubbyAvocado
ChubbyAvocadoOP14mo ago
@luna oh yeah that's important 🙏
luna
luna14mo ago
if you cant get that one working btw this very likely works with envs https://hub.docker.com/r/bitnami/kong/
ChubbyAvocado
ChubbyAvocadoOP14mo 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
Brody14mo 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
ChubbyAvocadoOP14mo ago
I see 😦
Brody
Brody14mo 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
ChubbyAvocadoOP14mo ago
@Brody Thanks for trying!
Brody
Brody14mo ago
sorry i couldnt solve it
ChubbyAvocado
ChubbyAvocadoOP14mo ago
maybe i will try find an alternative this point lol
Brody
Brody14mo ago
caddy
ChubbyAvocado
ChubbyAvocadoOP14mo 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
Brody14mo ago
im sure you could yeah https://caddyserver.com/
ChubbyAvocado
ChubbyAvocadoOP14mo ago
cool, I will check it out.
Want results from more Discord servers?
Add your server