Question
How to proxy Node.js error responses on NGINX?
I have an application server that is running a Sails.js Node application on top of NGINX. The application appears to be working correctly, however when the server accepts/rejects a request, the response body is empty. The response code is correct, however the body is completely empty. I can verify that the app is generating the correct responses using the applications debugging that I have in place.
This is the NGINX configuration that I have in place:
upstream local-upstream {
server 127.0.0.1:8080;
keepalive 64;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl on;
ssl_certificate XXX;
ssl_certificate_key XXX;
ssl_prefer_server_ciphers on;
## OCSP Stapling
resolver 127.0.0.1 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate XXX;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
#server_name _;
server_name app.quiqmath.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
proxy_pass http://local-upstream;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×