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;
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hi @jtittle I was able to speak with the developer of the Sails.js platform. Apparently there was some code hidden away that clears out the data response in production environments within certain types of responses. A 400 response happen to be one of those responses. I am super sorry for the confusion.
@dniccumdesign THANK YOU! After long testing this setup is properly forwarding all the headers from nginx to node app.
what was missing in that list is : proxy_pass (your proxy ip, port);
Definitely problem with the node app, what it helped me is to echo all headers, and get 200response (instead of 401 or 502):
var server = require(‘http’).createServer(function(req, res) { var host = req.headers; console.log(JSON.stringify(req.headers)); res.end(); });
server.listen(process.env.PORT || 8000);
@dniccumdesign
In place of:
Please try:
Once those changes are made, please restart NGINX:
If you run in to any errors along the way, please tail the logs and let’s take a look: