Nginx returning 401

Maxim Dounin mdounin at
Wed Sep 21 10:51:03 UTC 2022


On Wed, Sep 21, 2022 at 06:39:25AM -0400, suryamohan05 wrote:

> We are using nginx as reverse proxy in our project. When connecting to cloud
> server, Nginx returns 401 and then 200. But when connecting to on premise
> server it is returning 401. 
> In debug logs we are seeing SSL_get_error: 5 , SSL_get_error: 2
> SSL_get_error: -1. what does this SSL_get_error return type mean... Is there
> anyway to find the cause of this issue.

SSL_get_error() is an OpenSSL function used to retrieve status of 
various SSL-related operations.  It is completely unrelated to the 
HTTP return codes you are seeing.

When nginx is configured as a reverse proxy, HTTP status codes 
like 200 and 401 are usually returned by the upstream server, and 
only proxied by nginx.  First of all, you may want to make sure 
that this is what happens in your case.  Relevant information for 
sure can be found in the debug log, or you can use the 
$upstream_status variable to get the details without debugging 
($upstream_status).  And, as long as responses 
are indeed returned by the upstream server, you may want to start 
looking at the upstream server instead.

Hope this helps.

Maxim Dounin

More information about the nginx mailing list