Nginx – serving static content with nginx

nginxruby-on-railsstatic-content

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 🙂

Best Answer

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