Forum: NGINX nginx to nginx proxy header problem.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
14eddebaded16496d1198b2e43d44946?d=identicon&s=25 Jauder Ho (jauderho)
on 2009-03-06 06:12
I have nginx proxying to nginx+fcgi and it looks like the Vary header is
being set twice. The reason for this config is that I intend to stick a
Varnish instance in between but wanted to make sure this was working
before.

Both instances have pretty much the same config.

From the frontend instance:
curl -I http://shop.carumba.org
HTTP/1.1 200 OK
Server: Hai
Date: Fri, 06 Mar 2009 05:02:38 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
Vary: Accept-Encoding
Set-Cookie: frontend=a5c6d3165679d1abdbc173205f2239da; expires=Fri, 06
Mar 2009 06:02:38 GMT; path=/; domain=shop.carumba.org; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache


From the backend instance:
HTTP/1.1 200 OK
Server: Hai
Date: Fri, 06 Mar 2009 05:02:56 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
Set-Cookie: frontend=9e9f8cb77126971bb0798fa7324bda30; expires=Fri, 06
Mar 2009 06:02:55 GMT; path=/; domain=shop.carumba.org; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache


As you can see, there is an additional Vary: header for some odd reason.



For completeness, the following are responses for a static file.
a001:/usr/local/nginx/conf/carumba$ curl -I --compressed
http://shop.carumba.org/skin/frontend/default/blan...
HTTP/1.1 200 OK
Server: Hai
Date: Fri, 06 Mar 2009 05:10:36 GMT
Content-Type: text/css
Last-Modified: Wed, 18 Feb 2009 07:22:32 GMT
Connection: keep-alive
Vary: Accept-Encoding
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: max-age=315360000
Content-Encoding: gzip

a001:/usr/local/nginx/conf/carumba$ curl -I
http://shop.carumba.org/skin/frontend/default/blan...
HTTP/1.1 200 OK
Server: Hai
Date: Fri, 06 Mar 2009 05:10:49 GMT
Content-Type: text/css
Content-Length: 2834
Last-Modified: Wed, 18 Feb 2009 07:22:32 GMT
Connection: keep-alive
Vary: Accept-Encoding
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: max-age=315360000
Accept-Ranges: bytes


This is with nginx 0.7.38
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-03-06 08:45
(Received via mailing list)
On Fri, Mar 06, 2009 at 06:12:55AM +0100, Jauder Ho wrote:

> Server: Hai
> Pragma: no-cache
> Mar 2009 06:02:55 GMT; path=/; domain=shop.carumba.org; HttpOnly
> For completeness, the following are responses for a static file.
> Cache-Control: max-age=315360000
> Connection: keep-alive
> Vary: Accept-Encoding
> Expires: Thu, 31 Dec 2037 23:55:55 GMT
> Cache-Control: max-age=315360000
> Accept-Ranges: bytes
>
>
> This is with nginx 0.7.38

You should remove
  gzip on;
on one of the nginxes. Or add
  gzip_vary  off;
14eddebaded16496d1198b2e43d44946?d=identicon&s=25 Jauder Ho (jauderho)
on 2009-03-06 18:57
Igor,

Thanks. Setting gzip_vary off on the backend server seems to do the
trick.

I opted not to set gzip to off as the backend is directly accessible and
I still wanted the benefits of having gzip on.

--Jauder
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-03-07 11:25
(Received via mailing list)
On Fri, Mar 06, 2009 at 06:57:25PM +0100, Jauder Ho wrote:

> Thanks. Setting gzip_vary off on the backend server seems to do the
> trick.
>
> I opted not to set gzip to off as the backend is directly accessible and
> I still wanted the benefits of having gzip on.

You should set
  gzip       on;
  gzip_vary  [on|off];

only on one nginx. On other you should just set
  gzip       off;

Setting gzip_vary to "on" or "off" depends whether you want to add
the "Veryi: Accept-Encoding" header.
14eddebaded16496d1198b2e43d44946?d=identicon&s=25 Jauder Ho (jauderho)
on 2009-03-07 20:44
The Nginx wiki states that gzip and gzip_vary can be set within a
location directive. However, it does not appear to be working for me.
Setting it within a server directive does work.

http://wiki.codemongers.com/NginxHttpGzipModule#gzip_vary

So is the wiki or code incorrect?

--Jauder


Igor Sysoev wrote:

>
> You should set
>   gzip       on;
>   gzip_vary  [on|off];
>
> only on one nginx. On other you should just set
>   gzip       off;
>
> Setting gzip_vary to "on" or "off" depends whether you want to add
> the "Veryi: Accept-Encoding" header.
This topic is locked and can not be replied to.