If a platform injects PORT=3000 (e.g. Railway), nginx and Next.js would both try to bind port 3000. Use a dedicated internal port (7901) for the nginx→Next.js proxy to prevent this.
28 lines
778 B
Nginx Configuration File
28 lines
778 B
Nginx Configuration File
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
server {
|
|
listen ${PORT};
|
|
listen [::]:${PORT};
|
|
|
|
location /websockets {
|
|
proxy_pass http://${HOSTNAME}:3001;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "Upgrade";
|
|
proxy_set_header Host $http_host;
|
|
}
|
|
|
|
location / {
|
|
proxy_pass http://${HOSTNAME}:${INTERNAL_NEXTJS_PORT};
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
|
client_max_body_size 32M;
|
|
}
|
|
}
|
|
}
|