Override Content-Type header with proxied requests

António P. P. Almeida appa at perusio.net
Thu May 23 15:24:07 UTC 2013


Try this.

At the http level define a map directive that maps upstream Content-Types
to the correct ones.

map $upstream_content_type $s3_content_type {
    # S3 -> real...
}

On the location that proxy passes.

proxy_hide_header Content-Type;
add_header Content-Type $s3_content_type;

----appa



On Thu, May 23, 2013 at 5:07 PM, andrea.mandolo <nginx-forum at nginx.us>wrote:

> Hi !!
>
> i have a Nginx server that operates as a reverse proxy to a my bucket in
> Amazon S3.
>
> Amazon S3 service could deliver contents with wrong Content-Type header,
> so i would like to override this header by referring to file extension.
>
> In other servers i have just configured the "types" block with all mime
> types mapped with file estensions,
> but this approach only works when Nginx delivers contents directly (as a
> origin server).
> If the server is a reverse proxy, doesn't add a new Content-Type header,
> but
> honors Content-Type (if exists) received by the origin.
>
> Is it possible to override the content-type response header using "types"
> block? Is there any best practice to override content-type header by file
> extensions? Is "map" suggested for this purpose or using multiple
> "location"
> block is better?
>
> Thanks in advance!!
> ---
> Andrea
>
> Posted at Nginx Forum:
> http://forum.nginx.org/read.php?2,239473,239473#msg-239473
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130523/578f40ea/attachment.html>


More information about the nginx mailing list