proxy_hide_header hiding header from ALL locations

W. Andrew Loe III andrew at andrewloe.com
Thu Jul 29 01:47:28 MSD 2010


It looks like Content-Type is special cased:

Changes with nginx 0.3.58                                        14 Aug 2006

    *) Feature: the "error_page" directive supports the variables.

    *) Change: now the procfs interface instead of sysctl is used on Linux.

    *) Change: now the "Content-Type" header line is inherited from first
       response when the "X-Accel-Redirect" was used.

How can I get this behavior for ETag and Last-Modified as well?

On Wed, Jul 28, 2010 at 2:26 PM, W. Andrew Loe III <andrew at andrewloe.com> wrote:
> I have a two phase setup commonly implemented with S3.
>
> I want to set ETag and Last-Modified in my Rails application and have
> them take precedence over the S3 ETag and Last-Modified.
>
> location ^~ /AWSS3/ {
>  # Prevent Client headers from going to nginx.
>  proxy_pass_request_headers off;
>
>  # Prevent nginx from overwriting our headers.
>  proxy_hide_header "Content-Type";
>  proxy_hide_header "Last-Modified";
>  proxy_hide_header "ETag";
>  proxy_hide_header "Content-Disposition";
>
>  # Hide Amazon Headers
>  proxy_hide_header X-Amz-Id-2;
>  proxy_hide_header X-Amz-Request-Id;
>
>  # Have Amazon do the work buffering the request.
>  proxy_set_header Host 's3.amazonaws.com'; # the bucket is specified in the url
>
>  # Force Amazon to do the heavy lifting.
>  proxy_buffering off;
>
>  # Retry if Amazon freaks out
>  proxy_next_upstream error timeout http_500 http_502 http_503 http_504;
>
>  # Ensure the requests are always gets.
>  proxy_method GET;
>  proxy_pass_request_body off;
>  proxy_set_header Content-Length "";
>
>  # Proxy to S3.
>  proxy_pass http://s3/;
>  proxy_hide_header ETag;
>  proxy_hide_header Last-Modified;
>
>  internal;
> }
>
> What I see on my client is a valid Content-Type and
> Content-Disposition set by my Rails application but ETag and
> Last-Modified are not set. If I remove those proxy_hide_header
> directives the Headers are present but they are the values S3 returns
> not the values I returned from Rails.
>



More information about the nginx mailing list