Nginx Nodejs Raspberry Pi2 Bad Gateway

Francis Daly francis at
Wed Apr 26 21:18:20 UTC 2017

On Tue, Apr 25, 2017 at 10:13:19AM -0400, marciokoko wrote:

Hi there,

I confess that it's a bit confusing to me what exactly you are doing here.

Can you create one "curl" command which makes one request, that gives
a response that is not what you want to see?

If you can show what you expect to see instead, that might be helpful too.

If at all possible, copy-paste the pieces you are reporting, rather than
re-typing things.

It looks like there may be some typographical errors in what you report
here, which might be what is unclear to me.

> INTERNET ( A Record to public IP 186....187)
> -----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 

I *think* that the intention here is that a https request gets to nginx,
and then nginx makes a http request to the port-442 listener.

Can you show the request that gets to nginx, and the request that gets
to port 442, and see what the port-442 listener does with it?

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

Unless you have a location{} that matches those html urls, they may be
proxy_pass'ed to port 442 as well, which may make it more difficult than
necessary to interpret the log files.

> 2017/04/23 20:08:38 [error] 20424#0: *4 upstream prematurely closed
> connection while reading response header from upstream, client:
>, server:, request: "GET /aism/ HTTP/1.1",
> upstream: "", host: ""

"upstream prematurely closed connection" suggests that nginx thinks that
the port 442 listener did something wrong. Are there logs of what the
port 442 listener thinks happened?

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list