Welcome! Log In Create A New Profile

Advanced

Help with nginx second request

Эмануил Кант
November 13, 2019 09:40AM
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;
       }

================================
Request and responses:
================================
curl -i -X POST localhost/test500

HTTP/1.1 500 Internal Server Error
Server: nginx
Date: Wed, 13 Nov 2019 14:21:25 GMT
Content-Type: text/html
Content-Length: 13
Connection: close
ETag: "5dcbd0b0-d"
ERROR 500 page.


ngrep -qiltW byline -s 1000 -c 1024 -d lo '' port 90


T 2019/11/13 14:25:08.751892 127.0.0.1:44416 -> 127.0.0.1:90 [AP] #4
POST /test500 HTTP/1.1.
X-Forwarded-For: 127.0.0.1.
Host: localhost.
X-Forwarded-Proto: http.
User-Agent: curl/7.58.0.
Accept: */*.

T 2019/11/13 14:25:08.752038 127.0.0.1:90 -> 127.0.0.1:44416 [AFP] #6
HTTP/1.1 500 Internal Server Error.
Server: nginx.
Date: Wed, 13 Nov 2019 14:25:08 GMT.
Content-Type: text/html.
Content-Length: 13.
Connection: close.
ETag: "5dcbd0b0-d".
ERROR 500 page.

T 2019/11/13 14:25:08.752139 127.0.0.1:44418 -> 127.0.0.1:90 [AP] #12
POST /test500 HTTP/1.1.
X-Forwarded-For: 127.0.0.1.
Host: localhost.
X-Forwarded-Proto: http.
User-Agent: curl/7.58.0.
Accept: */*.

T 2019/11/13 14:25:08.752221 127.0.0.1:90 -> 127.0.0.1:44418 [AFP] #14
HTTP/1.1 500 Internal Server Error.
Server: nginx.
Date: Wed, 13 Nov 2019 14:25:08 GMT.
Content-Type: text/html.
Content-Length: 13.
Connection: close.
ETag: "5dcbd0b0-d".
ERROR 500 page.

So, in the response we see that nginx makes second request.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Help with nginx second request

Эмануил Кант November 13, 2019 09:40AM

Re: Help with nginx second request

Maxim Dounin November 19, 2019 10:40AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 78
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready