Commit Graph

124 Commits

Author SHA1 Message Date
Valentin Bartenev
f7673bb50f HTTP/2: the "421 Misdirected Request" response (closes #848).
Since 4fbef397c753 nginx rejects with the 400 error any attempts of
requesting different host over the same connection, if the relevant
virtual server requires verification of a client certificate.

While requesting hosts other than negotiated isn't something legal
in HTTP/1.x, the HTTP/2 specification explicitly permits such requests
for connection reuse and has introduced a special response code 421.

According to RFC 7540 Section 9.1.2 this code can be sent by a server
that is not configured to produce responses for the combination of
scheme and authority that are included in the request URI.  And the
client may retry the request over a different connection.

Now this code is used for requests that aren't authorized in current
connection.  After receiving the 421 response a client will be able
to open a new connection, provide the required certificate and retry
the request.

Unfortunately, not all clients currently are able to handle it well.
Notably Chrome just shows an error, while at least the latest version
of Firefox retries the request over a new connection.
2016-05-20 18:41:17 +03:00
Maxim Dounin
890ba54497 Backed out server_tokens changes.
Backed out changesets: cf3e75cfa951, 6b72414dfb4f, 602dc42035fe, e5076b96fd01.
2016-03-22 16:58:38 +03:00
Ruslan Ermilov
0b768c1435 Reconsidered server_tokens with an empty value.
An empty value will be treated as "off".
2016-03-22 15:52:28 +03:00
Ruslan Ermilov
86927c6588 Added variables support to server_tokens.
It can now be set to "off" conditionally, e.g. using the map
directive.

An empty value will disable the emission of the Server: header
and the signature in error messages generated by nginx.

Any other value is treated as "on", meaning that full nginx
version is emitted in the Server: header and error messages
generated by nginx.
2016-03-15 13:36:19 +03:00
Ruslan Ermilov
f0f7b437b9 Reduced the number of GET method constants. 2015-11-30 12:04:35 +03:00
Sergey Kandaurov
99bf1b56ec Fixed invalid access to complex value defined as an empty string.
Found by Valgrind.
2015-03-31 17:45:50 +03:00
Sergey Kandaurov
e09741ba06 Format specifier fixes in error logging. 2013-08-20 20:47:16 +04:00
Maxim Dounin
c4a4a6a5d8 Request body: improved handling of incorrect chunked request body.
While discarding chunked request body in some cases after detecting
request body corruption no error was returned, while it was possible
to correctly return 400 Bad Request.  If error is detected too late,
make sure to properly close connection.

Additionally, in ngx_http_special_response_handler() don't return body
of 500 Internal Server Error to a client if ngx_http_discard_request_body()
fails, but disable keepalive and continue.
2012-11-26 18:00:14 +00:00
Maxim Dounin
ab5ac3b095 Request body: fixed "501 Not Implemented" error handling.
It is not about "Method" but a generic message, and is expected to be used
e.g. if specified Transfer-Encoding is not supported.  Fixed message to
match RFC 2616.

Additionally, disable keepalive on such errors as we won't be able to read
request body correctly if we don't understand Transfer-Encoding used.
2012-11-21 00:54:01 +00:00
Maxim Dounin
c96c4196f3 Entity tags: clear on entity changes. 2012-07-07 21:22:27 +00:00
Ruslan Ermilov
1c57fb8790 Added support for the 307 Temporary Redirect. 2012-02-27 11:43:40 +00:00
Ruslan Ermilov
09422e632f Renamed constants and fixed off-by-one error in "msie_padding on" handling. 2012-02-22 16:23:29 +00:00
Maxim Konovalov
f8d59e33f3 Copyright updated. 2012-01-18 15:07:43 +00:00
Maxim Dounin
72df0f400a Clear old Location header (if any) while adding a new one.
This prevents incorrect behaviour when another redirect is issued within
error_page 302 handler.
2011-10-12 13:28:03 +00:00
Ruslan Ermilov
51a2423633 Stylistic change in checking the boolean expression. 2011-10-12 09:27:34 +00:00
Maxim Dounin
bfb42ad97c Fix for incorrect 201 replies from dav module.
Replies with 201 code contain body, and we should clearly indicate it's
empty if it's empty.  Before 0.8.32 chunked was explicitly disabled for
201 replies and as a result empty body was indicated by connection close
(not perfect, but worked).  Since 0.8.32 chunked is enabled, and this
causes incorrect responses from dav module when HTTP/1.1 is used: with
"Transfer-Encoding: chunked" but no chunks at all.

Fix is to actually return empty body in special response handler instead
of abusing r->header_only flag.

See here for initial report:
http://mailman.nginx.org/pipermail/nginx-ru/2010-October/037535.html
2011-09-27 11:09:55 +00:00
Igor Sysoev
64d5f9ba26 fix "error_page 497 https://" case
patch by Maxim Dounin
the bug has been introduced in r3782
2011-02-01 16:18:55 +00:00
Igor Sysoev
26cf2c96ea introduce 494 code "Request Header Too Large" 2011-01-20 10:37:58 +00:00
Igor Sysoev
f00e81d75a rename NGX_HTTP_OWN_CODES to NGX_HTTP_NGINX_CODES 2010-12-14 23:04:26 +00:00
Igor Sysoev
a64b716b22 allow override redirect status in error_page 2010-10-18 10:14:00 +00:00
Igor Sysoev
fb7b45d20e remove r->zero_body unused since the previous commit 2010-06-30 14:42:15 +00:00
Igor Sysoev
ebd883092b 303 See Other 2010-06-18 14:58:52 +00:00
Igor Sysoev
de0b1d6f12 remove r->zero_in_uri 2010-05-24 12:35:10 +00:00
Igor Sysoev
05b1a8f1e3 ngx_str_set() and ngx_str_null() 2010-05-14 09:56:37 +00:00
Igor Sysoev
3d12873adb add MSIE padding for Chrome too 2009-11-12 14:24:22 +00:00
Igor Sysoev
60190068ab reset content_type hash value, this fixes a bug when XSLT responses
could not be processed by SSI, charset, and gzip filters
2009-05-25 09:06:29 +00:00
Igor Sysoev
3adecaf121 fix the previous commit 2009-05-08 18:11:18 +00:00
Igor Sysoev
ad0b9303d0 allow to pass image filter errors via the same location where the filter is set 2009-05-08 14:52:50 +00:00
Igor Sysoev
fd4191845b handle big responses for "size" and "test" image_filters 2009-05-08 14:25:51 +00:00
Igor Sysoev
71d1f49268 ngx_http_filter_finalize_request() and ngx_http_clean_header() 2009-05-01 18:41:07 +00:00
Igor Sysoev
395f895900 allow any status 2009-04-11 11:05:15 +00:00
Igor Sysoev
64851bb2ae fix r2590: error_page made an external redirect without query string 2009-04-07 15:50:08 +00:00
Igor Sysoev
17f0e66bd9 use complex value in error_page 2009-03-22 09:40:04 +00:00
Igor Sysoev
303df47fcb send "100 Continue" just before reading request body 2008-12-26 13:43:42 +00:00
Igor Sysoev
1a8cbb8663 leave HEAD method while error_page redirection 2008-08-19 18:55:46 +00:00
Igor Sysoev
c9482c6ead do not discard body while error_page redirection 2008-08-19 12:23:18 +00:00
Igor Sysoev
d1853490da disable error_page loop in 500 error when recursive errors are enabled 2008-08-13 09:00:13 +00:00
Igor Sysoev
9709aaa2f4 fix building by bcc/etc introduced in r2038 2008-05-28 12:26:20 +00:00
Igor Sysoev
d412ece2fc fix debug logging 2008-05-26 18:49:36 +00:00
Igor Sysoev
3b30476068 style fix 2008-05-22 12:09:41 +00:00
Igor Sysoev
cdd4354b49 style fix 2008-05-21 17:39:51 +00:00
Igor Sysoev
615fe7f4be args support in static error_page 2008-04-29 10:06:43 +00:00
Igor Sysoev
15a20079a5 do not change method while error redirection to named location 2008-03-10 14:36:42 +00:00
Igor Sysoev
77e8b0c59f fix comment 2007-11-30 22:06:48 +00:00
Igor Sysoev
e430ab4d55 divide special response handling into several functions
fix "?" escaping introduced in r1467
2007-10-26 16:17:17 +00:00
Igor Sysoev
070cf22ab4 server_tokens 2007-10-22 10:17:34 +00:00
Igor Sysoev
832571f0fc rename ngx_http_discard_body() to ngx_http_discard_request_body() 2007-08-06 15:37:22 +00:00
Igor Sysoev
8889b65711 named location 2007-07-29 18:11:39 +00:00
Igor Sysoev
8662b6bec5 msie_refresh should escape at least '"' to prevent XSS 2007-07-13 09:37:01 +00:00
Igor Sysoev
da7281a6da NGX_HTTP_PRECONDITION_FAILED 2007-01-18 20:51:51 +00:00