Changeset 6749:f88a145b093e in nginx


Ignore:
Timestamp:
05/20/16 15:41:17 (17 months ago)
Author:
Valentin Bartenev <vbart@…>
Branch:
stable-1.10
Graft:
6556:654d2dae97d3
Message:

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.

Location:
src/http
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/http/ngx_http_header_filter_module.c

    r6451 r6556  
    9696    ngx_string("415 Unsupported Media Type"),
    9797    ngx_string("416 Requested Range Not Satisfiable"),
    98 
    99     /* ngx_null_string, */  /* "417 Expectation Failed" */
    100     /* ngx_null_string, */  /* "418 unused" */
    101     /* ngx_null_string, */  /* "419 unused" */
    102     /* ngx_null_string, */  /* "420 unused" */
    103     /* ngx_null_string, */  /* "421 unused" */
     98    ngx_null_string,  /* "417 Expectation Failed" */
     99    ngx_null_string,  /* "418 unused" */
     100    ngx_null_string,  /* "419 unused" */
     101    ngx_null_string,  /* "420 unused" */
     102    ngx_string("421 Misdirected Request"),
     103
    104104    /* ngx_null_string, */  /* "422 Unprocessable Entity" */
    105105    /* ngx_null_string, */  /* "423 Locked" */
    106106    /* ngx_null_string, */  /* "424 Failed Dependency" */
    107107
    108 #define NGX_HTTP_LAST_4XX  417
     108#define NGX_HTTP_LAST_4XX  422
    109109#define NGX_HTTP_OFF_5XX   (NGX_HTTP_LAST_4XX - 400 + NGX_HTTP_OFF_4XX)
    110110
     
    114114    ngx_string("503 Service Temporarily Unavailable"),
    115115    ngx_string("504 Gateway Time-out"),
    116 
    117116    ngx_null_string,        /* "505 HTTP Version Not Supported" */
    118117    ngx_null_string,        /* "506 Variant Also Negotiates" */
    119118    ngx_string("507 Insufficient Storage"),
     119
    120120    /* ngx_null_string, */  /* "508 unused" */
    121121    /* ngx_null_string, */  /* "509 unused" */
  • src/http/ngx_http_request.c

    r6480 r6749  
    20662066                          "client attempted to request the server name "
    20672067                          "different from that one was negotiated");
    2068             ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
     2068            ngx_http_finalize_request(r, NGX_HTTP_MISDIRECTED_REQUEST);
    20692069            return NGX_ERROR;
    20702070        }
  • src/http/ngx_http_request.h

    r6496 r6749  
    9696#define NGX_HTTP_UNSUPPORTED_MEDIA_TYPE    415
    9797#define NGX_HTTP_RANGE_NOT_SATISFIABLE     416
     98#define NGX_HTTP_MISDIRECTED_REQUEST       421
    9899
    99100
  • src/http/ngx_http_special_response.c

    r6451 r6556  
    208208"<body bgcolor=\"white\">" CRLF
    209209"<center><h1>416 Requested Range Not Satisfiable</h1></center>" CRLF
     210;
     211
     212
     213static char ngx_http_error_421_page[] =
     214"<html>" CRLF
     215"<head><title>421 Misdirected Request</title></head>" CRLF
     216"<body bgcolor=\"white\">" CRLF
     217"<center><h1>421 Misdirected Request</h1></center>" CRLF
    210218;
    211219
     
    335343    ngx_string(ngx_http_error_415_page),
    336344    ngx_string(ngx_http_error_416_page),
    337 
    338 #define NGX_HTTP_LAST_4XX  417
     345    ngx_null_string,                     /* 417 */
     346    ngx_null_string,                     /* 418 */
     347    ngx_null_string,                     /* 419 */
     348    ngx_null_string,                     /* 420 */
     349    ngx_string(ngx_http_error_421_page),
     350
     351#define NGX_HTTP_LAST_4XX  422
    339352#define NGX_HTTP_OFF_5XX   (NGX_HTTP_LAST_4XX - 400 + NGX_HTTP_OFF_4XX)
    340353
Note: See TracChangeset for help on using the changeset viewer.