Welcome! Log In Create A New Profile

Advanced

Setting expires header bypasses app server

nmk
April 01, 2009 06:34AM
Hi all,

I have nginx proxying to a couple of thin servers.

For a request like /javascripts/foo.js a controller called 'javascripts' generates some dynamic js and caches it to $document_root/javascripts/foo.js.

The relevant part of the nginx config file:

[code]
root /apps/foo-app/current/public;

location / {
proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
proxy_max_temp_file_size 0;

if (-f $request_filename) {
break;
}

if (!-f $request_filename) {
proxy_pass http://thins;
break;
}

location ~* \.(js|css|jpg|jpeg|gif|png)$ {
if (-f $request_filename) {
expires max;
break;
}
}

}
[/code]

When request /javascripts/foo.js on the production app (hitting nginx) a 404 is returned directly instead if the request being passed to the app servers. I would expext the request to be passed to the app servers as the file is not on the filesystem. Why doesn't the !-f $request_filename condition (lines 15-18) apply?

If I remove the last portion of the nginx config file (the one which adds an expires header to static files) all works as expected.

Any idea what might be wrong?

Best,
Nickolay
Subject Author Posted

Setting expires header bypasses app server

nmk April 01, 2009 06:34AM

Re: Setting expires header bypasses app server

mike April 01, 2009 01:06PM

Re: Setting expires header bypasses app server

nmk April 02, 2009 01:41PM

Re: Setting expires header bypasses app server

mike April 02, 2009 02:20PM

Re: Setting expires header bypasses app server

Cliff Wells April 02, 2009 03:41PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 52
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready