Reputation: 3500
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
Upvotes: 2
Views: 1492
Reputation: 81
Try
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;
root /var/www/yoursitename/public;
}
Upvotes: 0
Reputation: 3024
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;
}
Upvotes: 2
Reputation: 10556
Try the following
location ~* .*\.(jpe?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html?)$ {
access_log off;
expires max;
}
Upvotes: 0