0

I'm currently struggling to get the static content served with nginx for my application. I'll give a bit of background information:

Server : Ubuntu 10.4 lucide Ruby : 1.8 application : /var/www/apps/current 'deployed with capistrano' nginx is listening on port 2006 I have 4 thin servers running on port 4000 -> 4004 for the application (cluster)

my nginx configuration file looks like this:

upstream thin {
        server 127.0.0.1:4000;
        server 127.0.0.1:4001;
        server 127.0.0.1:4002;
        server 127.0.0.1:4003;
}

server {
        listen 2006;
        server_name escomatch.tst;
        root /var/www/apps/current/public;
        index index.html index.html;

        try_files $uri/index.html $uri.html $uri @thin;

        location ~* \.(jpeg|jpg|gif|png|ico|css|bmp|js)$ {
                root /;
        }

        location @thin {
                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 off;
                proxy_pass http://thin;
        }
        error_page 500 502 503 504 /50x.html;

        location = /50x.html {
                root html;
        }
}

My application is reachable at http://85.255.206.157:2006/ but as you can see, there's no static content. I'm pretty new to this stuff, so if anyone can point out what I'm forgetting, I'd be a happy developer :)

4
  • 2
    Maybe in location ~* regex you should have "root /var/www/apps/current/public" ? – Roman May 16 '11 at 13:46
  • yes I figured that out after posting it :S it's working like a charm now.....learning new things every day with this server :) – NekoNova May 16 '11 at 13:55
  • Happens to me too :)) – Roman May 16 '11 at 14:01
  • 1
    Please consider validating one of the answers. – Intrepidd May 19 '11 at 10:11
0

the path under the rexex was wrong... solved it now by implementing Roman's comment.

0

You need no root directive in location ~* ... {} block as you have root already defined in server {} block.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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