你好,我有这个 nginx 设置:
server {
listen 80;
server_name xxxxxx.xx www.xxxxxxx.xx;
root /home/xxxx/public_html;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
#proxy_redirect off;
#proxy_cache_bypass $http_upgrade;
}
}
我的应用程序在 uploads/user 内创建文件夹,后跟用户 ID,然后将图像存储到其中。每个用户在 uploads/user/xxxx 中都有自己的文件夹。
ex.
/uploads/user/5878db663e67e3535a47c638/1085.github-logo.png
该应用程序在浏览器中运行良好,但当用户上传图像时,它无法显示,因此会出现 404 错误。
我能做些什么?
您可以使用try_files
提供静态内容(如果存在),否则遵循 NodeJS:
root /home/xxxx/public_html;
location / {
try_files $uri $uri/ @proxy;
}
location @proxy {
proxy_pass http://127.0.0.1:3000;
...
}
See 这个文件 http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files了解详情。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)