Setting headers

Maxim Dounin mdounin at
Mon Sep 28 14:54:58 UTC 2015


On Fri, Sep 25, 2015 at 04:20:41PM +0200, Joó Ádám wrote:

> Something that long bothered me, and perhaps has already been
> discussed, but I haven’t found anything on it: why is there no way to
> set arbitrary headers without using an extension module? I know that
> the `add_header` directive has been augmented with the `always` flag
> recently, but there’s still no way to freely change headers. I
> personally think this is something that one could expect from a web
> server.

The "add_header" directive allows to add headers, the 
"proxy_hide_header" directive allows to hide headers got from an 
upstream server.  These two combined allows mostly arbitrary 
modifications.  If you think these are not enough - please provide 
specific use cases.

> My specific scenario is that I want to implement server-side
> content-negotiation, by conditionally applying an XSL stylesheet and
> changing the content-type accordingly.

When using nginx XSLT filter module, it shouldn't be needed to 
modify Content-Type at all.  Use xsl:output media-type attribute 
instead to provide a correct media type from the stylesheet itself.

Maxim Dounin

More information about the nginx mailing list