Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 {
        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 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 :)

share|improve this question

migrated from May 19 '11 at 9:49

This question came from our site for professional and enthusiast programmers.

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
Please consider validating one of the answers. – Intrepidd May 19 '11 at 10:11
up vote 0 down vote accepted

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

share|improve this answer

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

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.