Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is my Nginx config the location block for adding expires max to content is causing issues with content from the /internal proxied sites. Commenting out the expires max location block allows the proxied sites to work as intended.

Nginx error log

2011/11/22 15:51:23 [error] 22124#0: *2 open() "/var/www/internal/static/javascripts/lib.js" failed (2: No such file or directory), client:, server:, request: "GET /internal/static/javascripts/lib.js?0.6.11RC1 HTTP/1.1", host: "", referrer: ""

Browser error

lib.js Failed to load resource: the server responded with a status of 404 (Not Found)


location /internal {
    proxy_pass        http://localhost:10001/internal/;
 .... more entries ....


server {
    listen   80;
    include www.conf;
server {
    listen 443;

    include proxy.conf;
    include www.conf;

    ssl on;


root /var/www;

location / {
    autoindex off;
    allow all;
    rewrite ^/$ /mainsite last;

location ~*  \.(jpg|jpeg|gif|css|png|js|ico)$ {
    expires max;

# hide protected files
location ~* \.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$ {
    deny all;

location ~ \.php$ {
    fastcgi_index index.php;
    include fastcgi_params;
    if (-f $request_filename) {

proxy_connect_timeout   59s;
proxy_send_timeout      600;
proxy_read_timeout      600;
proxy_buffer_size       64k;
proxy_buffers           16 32k;
proxy_pass_header       Set-Cookie;
proxy_redirect          off;
proxy_hide_header       Vary;

proxy_busy_buffers_size         64k;
proxy_temp_file_write_size      64k;

proxy_set_header        Accept-Encoding         '';
proxy_ignore_headers    Cache-Control           Expires;
proxy_set_header        Referer                 $http_referer;
proxy_set_header        Host                    $host;
proxy_set_header        Cookie                  $http_cookie;
proxy_set_header        X-Real-IP               $remote_addr;
proxy_set_header        X-Forwarded-Host        $host;
proxy_set_header        X-Forwarded-Server      $host;
proxy_set_header        X-Forwarded-For         $proxy_add_x_forwarded_for;
share|improve this question
anyone care to elaborate why I was downvoted? title unclear? too much info? – Thermionix Nov 22 '11 at 22:44

1 Answer 1

I ended up moving the expires block inside the / location block

location / {
    autoindex off;
    allow all;
    rewrite ^/$ /mainsite last;

    location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {                                                       
            expires max;                                                                                         
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.