Nginx Nodejs Raspberry Pi2 Bad Gateway

marciokoko nginx-forum at forum.nginx.org
Tue Apr 25 14:13:19 UTC 2017


This is what my setup looks like:

INTERNET (subdomain.domain.com A Record to public IP 186....187)
Hurl.it -----POST-----> Public IP:
https://186....187/API/switches?sw1?password=123456 -----> Linksys Router
IP:186...187:443 Port Forward to 192...53

ONLAN (nginx setup https with ssl from letsencrypt)
192....53 RPi2 nginx config bypass 192...53:442 . ------> nodejs app.js
listening on port 442 

This is my nginx config file:

[code]
server {
        listen 443 ssl;
        listen [::]:443 ssl;
        server_name subdomain.domain.com;

        ssl_certificate         
/etc/letsencrypt/live/subdomain.domain.com/fullchain.pem;
        ssl_certificate_key     
/etc/letsencrypt/live/subdomain.domain.com/privkey.pem;

        root /www/subdomain.domain.com/aism;
        index index.php index.html index.htm;

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;

        # Error & Access logs
        error_log /www/subdomain.domain.com/logs/error.log error;
        access_log /www/subdomain.domain.com/logs/access.log;

        location / {
                index index.html index.php;
                proxy_pass http://192.168.1.53:442;
                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;
        }
        location ~ /.well-known {
                allow all;
        }
        location /public {
                root /www/subdomain.domain.com/aism;
        }
        location ~
^/(images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/) {
        }
}[/code]

I have tested the nodejs app while on port 80 from hurl.it with the port
forward config for port 80 instead and it works perfectly.

Here is the current error log:

[quote]
OST /API/switches/sw1?password=123456 HTTP/1.1", upstream:
"http://192.168.1.53:442/50x.html", host: "subdomain.domain.com"
2017/04/23 20:08:38 [error] 20424#0: *4 upstream prematurely closed
connection while reading response header from upstream, client:
192.168.1.56, server: subdomain.domain.com, request: "GET /aism/ HTTP/1.1",
upstream: "http://192.168.1.53:442/aism/", host: "subdomain.domain.com"
2017/04/23 20:08:38 [error] 20424#0: *4 upstream prematurely closed
connection while reading response header from upstream, client:
192.168.1.56, server: subdomain.domain.com, request: "GET /aism/ HTTP/1.1",
upstream: "http://192.168.1.53:442/50x.html", host: "subdomain.domain.com"
2017/04/23 20:09:25 [error] 20467#0: *1 upstream prematurely closed
connection while reading response header from upstream, client:
23.20.198.108, server: subdomain.domain.com, request: "POST
/API/switches/sw1?password=123456 HTTP/1.1", upstream:
"http://192.168.1.53:442/API/switches/sw1?password=123456", host:
"subdomain.domain.com"
[/code]

Please help!

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,273837,273837#msg-273837



More information about the nginx mailing list