upstream app {
server localhost:3000;
}
server {
...
# If I comment this location out, images are displayed on the website
location ~* \.(?:jpg|jpeg|png|gif|swf|xml|txt|css|js)$ {
expires 6004800;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
...
location /app {
alias /path/to/app/public/;
try_files $uri $uri @app;
}
location @app {
rewrite /app(.*) $1 break;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $proxy_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://app;
proxy_redirect http://app/ /app/;
}
...
}
我在这方面挣扎了一段时间。我在nginx下的子文件夹中有一个快速应用程序。以上是我在/ sites-available /中的nginx文件中的代码。当我删除静态文件的位置时,应用程序的图像和css被代理,但是如果静态文件缓存位于nginx文件中,则快速应用程序的图像和css文件不会显示在网站上。与nginx快递js应用 - 服务子文件夹时与静态文件的冲突
请问有人可以帮忙吗?