#Manually setting PORT for Docker Image

62 messages · Page 1 of 1 (latest)

vapid prism
#

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

Documentation for Railway

sacred scaffoldBOT
#

Project ID: 34a3782b-6485-41f9-923a-6b3b9753ab6e

rose cypressBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

vapid prism
#

project id:
34a3782b-6485-41f9-923a-6b3b9753ab6e

south dagger
#

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

spiral dust
#

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

#

@vapid prism will need more info though, is port 8000 running an http server?

vapid prism
#

Locally I don’t have any issue making http requests to 8000 but something seems messed up with the deployment on railway 😔

spiral dust
#

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

vapid prism
spiral dust
#

there also stuff about SSL and HTTPS, and http2, make sure you only listen on http 1.1 with no SSL of any kind

vapid prism
spiral dust
#

you have set a PORT service variable to 8000 right?

vapid prism
#

yeah!

spiral dust
#

does Kong have a docker image?

vapid prism
spiral dust
#

ill see what i can do

#

kong listens on multiple ports

vapid prism
#

right 8000 is for proxy 8001 is admin api

#

8002 is admin dashboard

spiral dust
#

you cant access a railway service publicly from multiple ports

vapid prism
#

even if i only need to expose one port?

spiral dust
#

if you only care about exposing one port, then it doesnt matter

#

what do you want to expose? the admin gui?

vapid prism
#

8000

#

that's the proxy

spiral dust
#

how do you plan on configuring kong if you are exposing the proxy instead of the admin gui

vapid prism
#

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.

spiral dust
#

their docs suck, send me the page where they list all of the env vars you can use?

vapid prism
#

yeah lol

#

i also tried to find it once and this is the best i found so far

spiral dust
#

those arent env vars though

vapid prism
#

my understanding is that these map to env var

#

e.g. proxy_listen -> KONG_PORXY_LISTEN

tough bear
#

you're missing the KONG prefix

spiral dust
#

dumb

tough bear
#

but yes those should all map over

vapid prism
#

@tough bear oh yeah that's important 🙏

tough bear
vapid prism
#

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).

vapid prism
spiral dust
#

that for sure wouldnt work, the proxy listens on 0.0.0.0, and ipv4 address but the private network is ipv6 only

spiral dust
#

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>

i give up

vapid prism
#

@spiral dust Thanks for trying!

spiral dust
#

sorry i couldnt solve it

vapid prism
#

maybe i will try find an alternative this point lol

spiral dust
#

caddy

vapid prism
#

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.

spiral dust
#

im sure you could yeah