Welcome! Log In Create A New Profile

Advanced

Re: Special headers and X-Accel-Redirect

António P. P. Almeida
June 06, 2011 10:42AM
On 6 Jun 2011 15h33 WEST, kgorlo@gmail.com wrote:

> Ok,
>
> I've found solution (or workaround - if this is bug in nginx).
>
> I have to put:
>
> set $x_metadata $upstream_http_x_metadata;
>
> BEFORE
>
> rewrite ^/files(.*)$ $1 break;
>
> Could you please explain me why?

Because you're breaking the rewrite phase processing by issuing a
rewrite with a break. A break or return terminates the rewrite phase
so what you're saying to Nginx is: rewrite and do no more rewrite
phase processing on this location.

The set directive is part of the rewrite module which means that it's
processed during the rewrite phase. It's not a bug, it's the way it's
supposed to be.

location /files {
internal;
rewrite ^/files(.*)$ $1 break; ## Stops rewrite phase processing here

proxy_pass http://filestore;
proxy_hide_header Content-Type;
proxy_hide_header Content-Disposition;

set $x_metadata $upstream_http_x_metadata;

add_header X-metadata $x_metadata;
}


So the solution is to place *all* rewrite phase directives that you
want to be processed before the rewrite with the break flag.

location /files {
internal;

set $x_metadata $upstream_http_x_metadata;
add_header X-metadata $x_metadata;

rewrite ^/files(.*)$ $1 break;

proxy_pass http://filestore;
proxy_hide_header Content-Type;
proxy_hide_header Content-Disposition;
}

--- appa



_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Special headers and X-Accel-Redirect

Kamil Gorlo June 06, 2011 09:16AM

Re: Special headers and X-Accel-Redirect

Kamil Gorlo June 06, 2011 09:18AM

Re: Special headers and X-Accel-Redirect

Kamil Gorlo June 06, 2011 10:36AM

Re: Special headers and X-Accel-Redirect

António P. P. Almeida June 06, 2011 10:42AM

Re: Special headers and X-Accel-Redirect

wideawake August 28, 2012 07:43PM

Re: Special headers and X-Accel-Redirect

Igor Sysoev June 06, 2011 11:12AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 69
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready