Answer the question
In order to leave comments, you need to log in
How to connect Nginx + nodejs so that put and post do not give a 504 error or another?
Hey! I have a site on nodejs and I want everything to go through the nginx proxy. My config:
upstream nodejs {
server localhost:3000;
}
server {
listen 80;
server_name localhost;
root /home/dev/myApp;
location / {
try_files $uri $uri/ @nodejs;
}
error_log /var/log/nginx/myApp.error.log;
location @nodejs {
proxy_redirect off;
proxy_http_version 1.1;
proxy_pass http://nodejs;
proxy_set_header Host $host ;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
2016/04/05 14:04:38 [error] 16318#0: *6 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.1.112, server: localhost, request: "POST /login HTTP/1.1", upstream: "http://127.0.0.1:3000/login", host: "myApp.dev.lan", referrer: "http://myApp.dev.lan/login"
Answer the question
In order to leave comments, you need to log in
Try adding these lines to location @nodejs
:
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question