Dima Gimburg
Dima Gimburg

Reputation: 1466

can't load static files on amazon ec2 with nginx and nodejs express

i'm trying to load an express-generator page on my ec2 server and i'm continuously getting 404 for static files, such as the stylesheets.
http://screencast.com/t/fsqgZjmMYi
my files are located in /var/www/html/test/myapp there i initialized the express-generator skeleton. in the express app the configuration for the static directory are:

app.use(express.static(path.join(__dirname,'public')));

and in the etc/nginx/sites-availiable/default file the location block looks like this:

location / {
    proxy_pass http://127.0.0.1:3000;
    try_files $uri $uri/ = 404;
}

location ~ /(images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|robots.txt|humans.txt|favicon.ico){
    root /var/www/html/test/myapp/public;
    access_log off;
    expires max;
}

tried different ways such as comment the line in the express app.js and nothing.

thank you very much!

Upvotes: 0

Views: 1412

Answers (1)

shan1024
shan1024

Reputation: 1399

Change the location like this:

location ~ (/images|/img|/javascript|/js|/css|/stylesheets|/flash|/media|/static|robots.txt|humans.txt|favicon.ico)

Upvotes: 2

Related Questions