Trying to add expires on proxied content make images and css/js redirect

Jose de Paula Eufrasio Junior jose.junior at gmail.com
Wed Nov 4 04:23:54 MSK 2009


So, I have this config here:

       location /thelocation {
           if ($request_uri ~* "\.(ico|css|js|gif|jpe?g|png)$") {
               expires 15d;
               break;
           }
           proxy_set_header Host xxxxxxxxr;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass http://localhost:8080/thelocation;

       }

The thing is, I am getting redirects on images and css, some example
pieces of the headers:

I send
GET /thelocation/wp-content/plugins/contact-form-7/stylesheet.css HTTP/1.1


and I get:
HTTP/1.x 301 Moved Permanently

Location: http://xxxxxxxxxxxxxxxx/thelocation/thelocation/wp-content/plugins/contact-form-7/stylesheet.css/


As you can notice, it redirects to my location twice and with a / on the end.
If I remove the "if" part of the server location configuration,
everything works ok. This location is served by a wordpress that is
behind varnish. I also have gzip enabled on nginx.

Any help is welcome.

--
José de Paula Eufrásio Júnior (coredump)
MCSO, GRC Professional
http://core.eti.br





More information about the nginx mailing list