Welcome! Log In Create A New Profile

Advanced

add_header not allowed in server if blocks?

June 14, 2010 07:04PM
I'm trying to add support for google chrome frame to our nginx config the simple way would be to include a fragment in each server block which looks something like:
[code]
if ( $http_user_agent ~ chromeframe ) {
add_header X-UA-Compatible "chrome=1";
}
[/code]

The problem is for some reason add_header isn't allowed in server-if blocks on location-if blocks. I can't see or think of a reason why this shouldn't be allowed?

So I tried adding it and it seems to work without a problem. The following patch, made against 0.8.40, adds server if block support for both expires and add_header.

[code]
--- src/http/modules/ngx_http_headers_filter_module.c.orig 2010-06-14 23:48:58.000000000 +0100
+++ src/http/modules/ngx_http_headers_filter_module.c 2010-06-14 23:49:27.000000000 +0100
@@ -79,7 +79,7 @@

{ ngx_string("expires"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
- |NGX_CONF_TAKE12,
+ |NGX_HTTP_SIF_CONF|NGX_CONF_TAKE12,
ngx_http_headers_expires,
NGX_HTTP_LOC_CONF_OFFSET,
0,
@@ -87,7 +87,7 @@

{ ngx_string("add_header"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
- |NGX_CONF_TAKE2,
+ |NGX_HTTP_SIF_CONF|NGX_CONF_TAKE2,
ngx_http_headers_add,
NGX_HTTP_LOC_CONF_OFFSET,
0,
[/code]
Subject Author Posted

add_header not allowed in server if blocks?

steveh June 14, 2010 07:04PM

Re: add_header not allowed in server if blocks?

steveh June 14, 2010 08:29PM

Re: add_header not allowed in server if blocks?

Maxim Dounin June 14, 2010 09:44PM

Re: add_header not allowed in server if blocks?

steveh June 14, 2010 09:58PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 89
Record Number of Users: 8 on December 15, 2016
Record Number of Guests: 386 on August 02, 2016
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready