Will nginx return 502 without any log in certain case?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Will nginx return 502 without any log in certain case?

wld75
I have my nginx running on EC2(Amazon Linux)  behind ALB (Load Balancer of
AWS).
Usually it works just fine but very rarely ALB receive 502 bad gateway form
the EC2 instance.

I checked both access.log and error.log of nginx but there is no log for 502
bad gateway.
We asked AWS about the reason of 502, but they told us it should be problem
of web server running on EC2 instance.

After some googling, I found an article that when nginx sends TCP RST or TCP
FIN, it will return 502 without any log output.
So I'm suggesting I am facing this case, but it there any way to figure out
whether it is so or not?
And if so, is there any way to get some information about why TCP RST or TCP
FIN is caused?

Thanks in advance.

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

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Will nginx return 502 without any log in certain case?

Maxim Dounin
Hello!

On Fri, Sep 07, 2018 at 06:44:58AM -0400, Fumitaka Yanase wrote:

> I have my nginx running on EC2(Amazon Linux)  behind ALB (Load Balancer of
> AWS).
> Usually it works just fine but very rarely ALB receive 502 bad gateway form
> the EC2 instance.
>
> I checked both access.log and error.log of nginx but there is no log for 502
> bad gateway.
> We asked AWS about the reason of 502, but they told us it should be problem
> of web server running on EC2 instance.
>
> After some googling, I found an article that when nginx sends TCP RST or TCP
> FIN, it will return 502 without any log output.
> So I'm suggesting I am facing this case, but it there any way to figure out
> whether it is so or not?
> And if so, is there any way to get some information about why TCP RST or TCP
> FIN is caused?

If a HTTP response with status code 502 is returned by nginx, it
a) logs a message explaining the problem to the error log at the
"error" level and b) logs the request and the response status to
the access log.

If, however, a 502 error is generated by AWS load balancer, the
exact reason for the error is only known on the AWS load balancer
side.  Depending on what exactly happened, there may be something
in nginx logs (not necessary an error) or nothing at all (for
example, if the load balancer wasn't able to connect to nginx).

If you want to further debug this, first of all you may want to
find out where the errors you are seeing are generated.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx