Welcome! Log In Create A New Profile

Advanced

Reverse proxy - retry connection in response to error 50x

Posted by fj40 
Reverse proxy - retry connection in response to error 50x
October 21, 2014 03:03PM
I have a reverse proxy setup pointing to a single IIS server. On occasion, the backend IIS server throws a 500 that is easily resolvable by a browser refresh. Our developers are having trouble figuring out the actual cause of the 500, so I'd like to come up with a work-around.

I've read some posts about load balancing where it sounds like this should be possible, however my scenario has only one backend server rather than multiple.

Is there a way to have nginx automatically retry after receiving a 50x response?
Re: Reverse proxy - retry connection in response to error 50x
October 21, 2014 03:15PM
Show some nginx logfiles, preferably with debug mode on.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: Reverse proxy - retry connection in response to error 50x
October 21, 2014 05:14PM
From access.log:

10.1.21.114 - - [21/Oct/2014:14:01:55 -0700] "GET /xxxxx_prod/u2/cfs056.ashx?clearScreenInputs=UserID=QCFJB|GoFlag1=Y|GoFlag2=Y|GoFlag3=Y|GoFlag4=Y|GoFlag5=Y|Parm0=Y|Parm1=Y HTTP/1.1" 302 168 "https://xxxxx2.nv.gov/xxxxx_prod/u2/landing.aspx" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"
10.1.21.114 - - [21/Oct/2014:14:01:55 -0700] "GET /xxxxx_prod/u2/IefIEApplication.aspx?ID=0 HTTP/1.1" 200 938 "https://xxxxx2.nv.gov/xxxxx_prod/u2/landing.aspx" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"
10.1.21.114 - - [21/Oct/2014:14:01:55 -0700] "GET /xxxxx_prod/u2/IefWebForm.aspx?ID=0 HTTP/1.1" 500 5423 "https://xxxxx2.nv.gov/xxxxx_prod/u2/IefIEApplication.aspx?ID=0" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"

The last entry shows the 500 that I would like to handle with a retry.

There's no corresponding entry in error.log
Re: Reverse proxy - retry connection in response to error 50x
October 22, 2014 02:57AM
The problem is the backend here, nginx does not do a retry on its own as that would be blocking a worker, you might be able to do a retry via cosockets (Lua) as thats not blocking. Or create more backends and load balance them.
In short the backend can't handle what nginx is passing on.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: Reverse proxy - retry connection in response to error 50x
October 22, 2014 11:33AM
Thanks - I appreciate your advice. I've done more research and found that the error never occurs with a direct connection. It seems the application is expecting something that isn't being passed along via the proxy. The backend IIS reports that an "object reference is not set to an instance of an object." I'm not sure how to solve this, but retrying the connection probably isn't the best solution to my issue.

Thanks again for your help.
Re: Reverse proxy - retry connection in response to error 50x
October 22, 2014 02:07PM
You could try these settings to the proxy:
keepalive_requests 500;
proxy_http_version 1.1;

if that doesn't work your going to need a wireshark dump to see the difference, it sounds like some header is not getting passed.

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 181
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready