Support for relative URL in Location header

Jeroen Ooms jeroen.ooms at
Mon Nov 4 18:42:00 UTC 2013

HTTP status codes such as 201, 301, 302, etc rely on the HTTP Location
header. The current standard of HTTP specifies that this URL must be
absolute. However, all popular browsers will accept a relative URL,
and it is correct according to the upcoming revision of HTTP/1.1. See
also [1].

I noticed that the version of nginx that I'm running (1.1.9, ubuntu
precise) does not properly interpret a relative URL. The docs on
"proxy_redirect" state that "The default replacement specified by the
default parameter uses the parameters of the location and proxy_pass
directives. " [2]. However it does not work when the Location path is
relative. For example if:

location /one/ {
    proxy_pass     http://upstream:port/two/;
    proxy_redirect default;

Then a location header "http://upstream:port/two/" gets
rewritten to "/one/". However a location header "/two/"
does not get rewritten to "/one/", as it should if the relative
URL were supported.

Is this something that will, or already has been implemented in more
recent versions of nginx?


More information about the nginx mailing list