underscores_in_headers not functioning when using default option for listen directive

Maxim Dounin mdounin at mdounin.ru
Mon Dec 27 18:18:26 MSK 2010


Hello!

On Mon, Dec 27, 2010 at 03:38:10PM +0100, Sylvain Rabot wrote:

> On Mon, 2010-12-27 at 15:48 +0200, Maxim Dounin wrote:
> > Hello!
> > 
> > On Mon, Dec 27, 2010 at 01:21:14PM +0100, Sylvain Rabot wrote:
> > 
> > > Hi,
> > > 
> > > We are using nginx 0.7.68 and we encountered a small problem with the
> > > underscores_in_headers directive.
> > > 
> > > Use case, 2 servers section :
> > > 
> > > server {
> > > 	listen 80 default;
> > > 	server_name *.domain.com;
> > > 
> > > 	...
> > > }
> > > 
> > > server {
> > > 	listen 80;
> > > 	server_name titi.domain-b.com;
> > > 	underscores_in_headers on;
> > > 
> > > 	...
> > > }
> > > 
> > > In that case the underscores_in_headers directive of the second server
> > > is not taken care of.
> > 
> > This is expected.  Header parsing happens in context of default 
> > server, before server_name matching (as server_name matching 
> > requires parsing Host header).
> 
> It makes sense. So shouldn't this directive be in the 'http'
> configuration section only ?

No, it's still usable at server{} level for separate listen sockets 
(i.e. non-virtual servers).  Consider the following example:

server {
    listen 127.0.0.1:80;
    underscores_in_headers on;
    ...
}

server {
    listen 80;
    ...
}

Maxim Dounin



More information about the nginx mailing list