R
Railway

✋|help

nginx revere proxy 503 error

Ttheodor_m9/12/2023
Hi! I wanted to set up a reverse NGINX proxy with mixpanel.


I used the dockerfile provided by them:

FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf

And this configuration:
events {}
http {
    server {
        listen 80 default backlog=16384;
        listen [::]:80 default backlog=16384;

        location /lib.min.js {
            proxy_set_header X-Real-IP $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Host $server_name;
            proxy_pass https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js;
        }

        location /lib.js {
            proxy_set_header X-Real-IP $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Host $server_name;
            proxy_pass https://cdn.mxpnl.com/libs/mixpanel-2-latest.js;
        }

        location /decide {
            proxy_set_header Host decide.mixpanel.com;
            proxy_set_header X-Real-IP $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Host $server_name;
            proxy_pass https://decide.mixpanel.com/decide;
        }

        location / {
            proxy_set_header Host api.mixpanel.com;
            proxy_set_header X-Real-IP $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Host $server_name;
            proxy_pass https://api.mixpanel.com/;
        }
    }
}


I also enabled a custom domain which is verified (reverse-proxy.rizzgpt.app).

However, I'm getting a 503 when I try to load it. Any idea why?
Ttheodor_m9/12/2023
120b5ec5-59d8-4087-84ae-4e0b3d934aa7
BBrody9/12/2023
do
listen 8080 default backlog=16384;
listen [::]:8080 default backlog=16384;

instead
then set a service variable PORT=8080
Ttheodor_m9/12/2023
gotcha thanks!
it works! thanks!
BBrody9/12/2023
no problem 🙂
Ttheodor_m9/12/2023
why was that necessary?
just curious
BBrody9/12/2023
railway had no way of knowing nginx was listening on port 80
so i asked you to have nginx listen on 8080 purely for good practice since 8080 is an unprivlaged port, then you set PORT=8080 to tell railway what port your app listens on
Ttheodor_m9/12/2023
ah i see!
so PORT=8080 is the magic formula here
BBrody9/12/2023
railway randomly generates a PORT variable for you, normally you want to listen on that, but thats not exactly possible with nginx, so we have to resort to setting a fixed port

Looking for more? Join the community!

Recommended Posts
@railway/cli not running correctly when installed as a Bun devDependencyI have `@railway/cli` installed as a `devDependency` in my project. This has worked fine with me whiBun installHi, im trying to deploy a bun app to railway, nixpacks seems to have picked it up, but is trying to Memory MetricsDo the memory metrics represent the entire memroy being used by all the active process in that serviCan we easily add some config files for a dockerhub type of deployment ?https://docs.railway.app/develop/services#docker-image we can deploy from dockerhub and that's very TLS handshake timeout during transition from build to deployFull log message: ``` [us-west1] ========================= Using Detected Dockerfile =============Can I deploy an image from dockerhub directly ?Hello, all said in the title. I wanted to setup an opentelemetry collector and play with https://hubBuild->deploy Process suddenly brokei feel like you guys changed the way your containers are structured and it broke my build->deploy prRailway server sleep even purchase Hobby planhey guys, I paid for Hobby plan and I was successful deploy my nodejs server on railway last night, Node.js v18.12.1 is not supported by Astro, how to update to : ">=18.14.1"?Anyone can help me, please? Got this error while building Astro, how to update to : ">=18.14.1"? Tbundo railway have support for bun in the near feature?Issue Deploying Next.js 13 with Bun 1.0For better or worse I've decided to follow the hype train and am trying to get Bun 1.0 working with Pricing QuestionsI'm looking for some clarification regarding Railway's pricing structure. I've noticed that the 'HobDeploying via github always crashes after 4-5 minutesI am creating a discord bot and when I commit to github and deploy it, it starts fine at first. But Deploying bun 1.0in bun cause I don't need to build files is their somehow I can skip the build step since it alreadyWhere can you store Media Files?I'm using Django and have added a blog module to it where users can upload their own images. I was wEasy (?) shared variables questionThe environment contains the excellent Payload CMS template, attendant Mongo DB, and a Next.js frontPlan update issueIm having a issue with plan update. It just shows: Problem processing payment method and I triple cCan't create an account: Device requesting login is not supported. Please try again from a secure coTrying to create a new Railway Account, but getting this error: ```Device requesting login is not saccess to resource inside replicahi, when we setup an instance to have 2 replicas, how do we get the resource related to 1 of the reCommunicate between services with private networkProject ID: 3f51dcb4-6905-4a13-be75-4c6063e4324a I am trying to set up Railway to communicate betwe