nginx proxy_pass to private network
Hello, I am trying out the new private networking feature. I have a react application running in a service and a container running nginx in another service. I would like to have a public url for the nginx container, but only private for the react app. I setup nginx to do a reverse proxy to the app, which works fine if I use a public url for the react app, but I can't get to work at all with the private url.
nginx: [emerg] host not found in upstream "gsandf-com-app.railway.internal" in /etc/nginx/conf.d/default.conf:29
Also, is there an ENV variable like RAILWAY_SERVER_{name}_URL
for private urls?15 Replies
Project ID:
f44954e4-11aa-4f45-9e1a-302641b5dc42
f44954e4-11aa-4f45-9e1a-302641b5dc42
had to do
ENABLE_ALPINE_PRIVATE_NETWORKING=true
as it says at the bottom of the private networking doc pageare you using an alpine based image?
is it preferred to use a not-apline based image?
I prefer alpine based images myself, and I've never had a problem with alpine 3.18, I think it's only an issue with older alpine versions
but I'm curious, where you using an alpine based image to begin with?
I'm using
nginx:apline
cool, thanks for the info
Now its just giving me
[error] 31#31: *5 connect() failed (111: Connection refused) while connecting to upstream
nvm, the frontend seems to not be running, i'll fiddle around thank youyeah nginx:alpine uses apline 3.17, think this was fixed in 3.18
is this a create react app? if so, I have a handy guide to get those apps running if you want?
no its razzle (not my choice)
interesting, never heard of that
actually i added a public url and the app is running, but nginx just returns a 502
but a rule of thumb is, make sure you are running the app in a production mode, listen on all interfaces (ipv4 and ipv6 (private networking is ipv6 only)), and listen on the environment variable PORT, but for a private networking scenario you will want to set a fixed PORT variable in the service variables, otherwise railway assigns a random PORT and that's not gonna go well since you need to specify the PORT in the proxy pass string on the nginx config
a common misconception with the private networking domain railway gives you, it really is an internal network, so to connect to the service locally you need to specify the PORT in the connection string
so in the proxy_pass i need to put
https://{url}.internal:443
like when you run a service on your own computer, you have to specify the in the connection string like
<local or loopback ip address>:3000
to connect to the service locally, same thing with railways internal networking but just using the provided internal domain, name.railway.internal:3000
nope, this is a local network, your service does not run on HTTPS, or PORT 443 (or should not be runing on 443 at least) when running locally, you are treating the local domain as if it where a public domain