Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Node.js : Nginx won't serve static content

Node.js : Nginx won't serve static content

Problem

I am trying to server Static content via nginx on my node.js app. For the seemingly simple and obvious setup, I am not able to route the static content via nginx. With this line :

  location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$ {
                    access_log off;
                    expires max;
    }

nginx does not server any static content (js, css, images) - but on removing this I see that static contents are displayed. On Node side, I am using express and jade.

nginx.conf: https://gist.github.com/3331669

default: https://gist.github.com/3331674

Problem courtesy of: Ved

Solution

Try the following:

location ~  \.(jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$ {
  access_log off;
  expires max;
}
Solution courtesy of: matzahboy

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Node.js : Nginx won't serve static content

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×