如何解决Nginx:404 Not Found 错误作为反向代理
我正在尝试将 Nginx 配置为反向代理,将 Uvicorn 置于其后。
当我尝试访问“example.com”时,它返回主页,但为所有静态文件提供 404。
当我尝试访问任何其他端点(如“example.com/blog”)时,它返回“404 not found”页面。
这是 Nginx 配置:
new Vue({
// ...
methods: {
// ...
example: function () {
// modify data
this.message = 'changed'
// DOM is not updated yet
this.$nextTick(function () {
// DOM is now updated
// `this` is bound to the current instance
this.doSomethingElse()
})
}
}
})
我应该做哪些改变才能让它发挥作用?
解决方法
根据@richard-smith 在评论中给出的建议,我尝试注释掉这一行
location / {
#try_files $uri $uri/ =404; <-- here
#custom config
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://uvicorn;
}
而且效果很好。它现在能够为所有端点提供服务。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。