Help with nginx second request
Maxim Dounin
mdounin at mdounin.ru
Tue Nov 19 15:38:51 UTC 2019
Hello!
On Wed, Nov 13, 2019 at 04:38:54PM +0200, Эмануил Кант wrote:
> Hi all,
> I would really appreciate it if you could help me with nginx.
>
> The situation is:
> Nginx (v. 1.14.2) redirects the request to the application
> server. In case this request with the POST method and the
> application server gives an error code 500, the response is
> transmitted to the client.
> But nginx then makes a second request. Is there any way to
> disable execution of the second request by nginx?
> Many thanks in advance.
>
> Here is a part of nginx file:
>
> #Makes upstream to the branch with response code 500
> upstream test5 {
> server 127.0.0.1:90;
> keepalive 20;
> }
>
> #virtualhost that issues response code 500;
> server {
> listen 90 default_server;
> server_name localhost;
> root /home/jetty/www;
>
> location @intercept_disabled {
> proxy_intercept_errors off;
> proxy_pass http://test5;
> }
> location /test500 {
> return 500;
> error_page 500 /500.html;
> }
> }
>
> # Redirection to virtualhost that issues response code 500;
> location /test500 {
> proxy_pass http://test5;
> }
What else is configured in the server{} block with "location
/test500"?
Results you provide (that is, two duplicate requests) and the
unneeded "location @intercept_disabled" in the first server
suggests that you've configured proxy_intercept_errors and
"error_page 500" with a name-based location with additional
proxy_pass to the same server. And this is what causes duplicate
requests - because this is exactly what you've asked nginx to do.
An obvious solution is to remove this error handling or change it
to something different.
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx
mailing list