trying to output headers for status 414.
Added this to my vhost in nginx
more_set_headers -s 414 'X-Foo: Bar';
This still outputs the error page, but does not set headers.
@davecramer I've tried the following minimal example with the latest ngx_headers_more (v0.25) and nginx 1.5.11 and it works flawlessly:
location = /t {
return 414;
more_set_headers -s 414 'X-Foo: Bar';
}
Accessing /t with curl gives
$ curl -i localhost/t
HTTP/1.1 414 Request-URI Too Large
Server: nginx/1.5.11 (no pool)
Date: Thu, 27 Mar 2014 18:30:42 GMT
Content-Type: text/html
Content-Length: 203
Connection: close
X-Foo: Bar
<html>
<head><title>414 Request-URI Too Large</title></head>
<body bgcolor="white">
<center><h1>414 Request-URI Too Large</h1></center>
<hr><center>nginx/1.5.11 (no pool)</center>
</body>
</html>
Note the X-Foo: Bar response header is indeed there.
@agentzh
Yup that example works fine. However with a real URI that is too large it doesn't catch it.
I am using this in a reverse proxy and actually providing a request URI that is too large. Is it possible that it isn't handled properly in a vhost ?
Dave
Dave Cramer
On Thu, Mar 27, 2014 at 2:31 PM, Yichun Zhang [email protected]:
@davecramer https://github.com/davecramer I've tried the following minimal example with the latest ngx_headers_more (v0.25) and nginx 1.5.11 and it works flawlessly:
location = /t { return 414; more_set_headers -s 414 'X-Foo: Bar'; }Accessing /t with curl gives
$ curl -i localhost/t HTTP/1.1 414 Request-URI Too Large Server: nginx/1.5.11 (no pool) Date: Thu, 27 Mar 2014 18:30:42 GMT Content-Type: text/html Content-Length: 203 Connection: close X-Foo: Bar
414 Request-URI Too Large 414 Request-URI Too Large
nginx/1.5.11 (no pool) Note the X-Foo: Bar response header is indeed there.
Reply to this email directly or view it on GitHubhttps://github.com/agentzh/headers-more-nginx-module/issues/26#issuecomment-38842869 .
@davecramer
I am using this in a reverse proxy and actually providing a request URI that is too large. Is it possible that it isn't handled properly in a vhost
For this case, nginx throws out 414 very early, during reading and parsing the request header's first line. Because it happens so early, no location is matched against the current (guilty) request yet while your more_set_headers directive is a "location configuration" which only takes effect for a request that has already been associated with a location {} block.
same thing with status=206 when nginx responding with partial content. is there a way to catch these "late" status codes too?
@bAndie91 Not really. Better serve such "range" requests yourself directly in the content handler (like content_by_lua).
Any solutions from this? I also cannot get a header from status 414.
server {
listen 80;
...
error_page 414 /414.json;
location /414.json {
return 414 '{ "status": { "code": 414, "message": "URI TOO LONG", "debugId": $http_x_correlation_id } }';
}
}
Currently I'm passing X-Correlation-Id from the request, and the response returns empty x-correlation-id
return 414 '{ "status": { "code": 414, "message": "URI TOO LONG", "debugId": } }';