Welcome! Log In Create A New Profile

Advanced

Re: catching 408 response from upstream server

February 11, 2015 03:26PM
Hi,

Below is the debug_http log showing the same location handling upstream response of 409, and next of 408.
You can see that the 408 response is handled differently:

// ----------------409 -------------- //

2015/02/11 22:07:03 [debug] 20611#0: *3 http upstream process header
2015/02/11 22:07:03 [debug] 20611#0: *3 http proxy header done
2015/02/11 22:07:03 [debug] 20611#0: *3 finalize http upstream request: 409
2015/02/11 22:07:03 [debug] 20611#0: *3 finalize http proxy request
2015/02/11 22:07:03 [debug] 20611#0: *3 free rr peer 1 0
2015/02/11 22:07:03 [debug] 20611#0: *3 close http upstream connection: 12
2015/02/11 22:07:03 [debug] 20611#0: *3 http finalize request: 409, "/proxy/host_www.a.com/fallback_www.b.com/" a:1, c:1
2015/02/11 22:07:03 [debug] 20611#0: *3 http special response: 409, "/proxy/host_www.a.com/fallback_www.b.com/" // <-- handled as special response
2015/02/11 22:07:03 [debug] 20611#0: *3 http script var: "http://www.b.com/"
2015/02/11 22:07:03 [debug] 20611#0: *3 http log handler
2015/02/11 22:07:03 [debug] 20611#0: *3 HTTP/1.1 302 Moved Temporarily
Server: nginx
Date: Wed, 11 Feb 2015 20:07:03 GMT
Content-Type: text/html
Content-Length: 149
Connection: keep-alive
Location: http://www.b.com/


// ------------- 408 -------------- //

2015/02/11 22:05:03 [debug] 20611#0: *1 http upstream process header
2015/02/11 22:05:03 [debug] 20611#0: *1 http proxy header done
2015/02/11 22:05:03 [debug] 20611#0: *1 finalize http upstream request: 408
2015/02/11 22:05:03 [debug] 20611#0: *1 finalize http proxy request
2015/02/11 22:05:03 [debug] 20611#0: *1 free rr peer 1 0
2015/02/11 22:05:03 [debug] 20611#0: *1 close http upstream connection: 12
2015/02/11 22:05:03 [debug] 20611#0: *1 http finalize request: 408, "/proxy/host_www.a.com/fallback_www.b.com/" a:1, c:1
2015/02/11 22:05:03 [debug] 20611#0: *1 http terminate request count:1 // <-- handled by terminating the connection
2015/02/11 22:05:03 [debug] 20611#0: *1 http terminate cleanup count:1 blk:0
2015/02/11 22:05:03 [debug] 20611#0: *1 http posted request: "/proxy/host_www.a.com/fallback_www.b.com/"
2015/02/11 22:05:03 [debug] 20611#0: *1 http terminate handler count:1
2015/02/11 22:05:03 [debug] 20611#0: *1 http request count:1 blk:0
2015/02/11 22:05:03 [debug] 20611#0: *1 http close request

I've tried to follow this in code (by the way, i'm using version 1.6.2, sorry i didn't mention it earlier).
It seems that indeed response code 408 is handled differently. in function "ngx_http_finalize_request" i can see that code 408 is handled by calling "ngx_http_terminate_request", while other codes (like 409) are handled a few lines later with "ngx_http_special_response_handler" which also handles the error_page directive.

I've read in a different post in this forum that Nginx, by design, terminates the connection when it's configured to respond with 408 response code - for example when using "return 408" in a location. The post can be found here: http://forum.nginx.org/read.php?2,173195,173235#msg-173235

However in my case, i'm not generating an 408 response in Nginx. I'm trying to catch an 408 response from the upstream server, and turn it into a redirect.

As you said, the documentation doesn't say anything about error_page handling response code 408 differently, so i can't figure out if this behavior is intentional or not.

If intentional - i'd really like to understand the logic behind it, perhaps i'm looking at it all wrong.
If it's not intentional - i'd really like to find a way around this, to return a redirect to the client.

Thank you for your patience and help,
ShmulikB
Subject Author Posted

catching 408 response from upstream server

shmulik February 10, 2015 02:35AM

Re: catching 408 response from upstream server

B.R. February 10, 2015 04:00AM

Re: catching 408 response from upstream server

shmulik February 11, 2015 03:26PM

Re: catching 408 response from upstream server

shmulik February 11, 2015 03:34PM

Re: catching 408 response from upstream server

Frederik Nosi February 10, 2015 07:20AM

Re: catching 408 response from upstream server

shmulik February 11, 2015 03:33PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 186
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