[英]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. 我正在尝试在ec2服务器上加载一个Express-Generator页面,并且我不断获取404用于静态文件(例如样式表)。
http://screencast.com/t/fsqgZjmMYi http://screencast.com/t/fsqgZjmMYi
my files are located in /var/www/html/test/myapp there i initialized the express-generator skeleton. 我的文件位于/ var / www / html / test / myapp中,在那里我初始化了Express-Generator骨架。 in the express app the configuration for the static directory are:
在express应用中,静态目录的配置为:
app.use(express.static(path.join(__dirname,'public')));
and in the etc/nginx/sites-availiable/default file the location block looks like this: 在etc / nginx / sites-available / default文件中,位置块如下所示:
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. 尝试了其他方法,例如在快速app.js中注释行,什么也没做。
thank you very much! 非常感谢你!
像这样更改位置:
location ~ (/images|/img|/javascript|/js|/css|/stylesheets|/flash|/media|/static|robots.txt|humans.txt|favicon.ico)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.