nginx - 我的 Nginx 服务器静态内容显示 403 禁止错误。为什么?
问题描述
我用 gunicorn 部署了我的烧瓶应用程序,并让 nginx 提供静态内容。.conf 文件是这样的
server {
listen 80;
listen [::]:80;
server_name lab01.net;
location /static {
alias /home/lab01/blog/flaskblog/static;
autoindex on;
}
location / {
proxy_pass http://localhost:8000;
proxy_redirect off;
}
}
我认为配置是正确的,但是当我在浏览器http://lab01.net/static中访问静态文件时,发现 403 禁止错误。
然后我检查了 nginx 日志文件,日志文件一直说
2021/09/19 19:45:18 [error] 86998#0: *7 "/home/lab01/blog/flaskblog/static/index.html" is forbidden (13: Permission denied), client: 192.168.89.1, server: lab01.net, request: "GET /static/ HTTP/1.1", host: "lab01.net"
在日志文件中,它说/home/lab01/blog/flaskblog/static/index.html是被禁止的。为什么老是这样说?为什么服务器访问 index.html?在静态文件夹中只有图像和 css 文件。它应该访问这些文件而不是 index.html 吗???
注意:当我第一次在服务器上部署时,静态内容正确显示并且没有错误。在我将所有代码库切换到另一台服务器并重新配置 nginx 之后。我遇到这个错误。所有的防火墙和 SeLinux fcontext 和 boolean 也都配置好了。
解决方案
推荐阅读
- ios - 如何将数据从父模型类传递到 SwiftUI 中的子视图
- dart-html - onEvent.Listen() 和 addEventListener 的区别
- publish-subscribe - 如何在 dolphindb 中订阅流表
- r - 将纽约州法院数据中的数据转换为要可视化的数据框 R(导入但未成为正确的数据框)
- git - git-svn 死于信号 11
- java - 如何使用 kotlin 或 java 将倒数计时器设置为一天中的特定时间?
- python - 如何在 tkinter 中的屏幕/帧之间切换?
- jupyter-notebook - 无法在 OSX 10.11 中使用 xeus-cling 内核
- android - 如何在 Android Studio 中添加 gradle 的任务参数?
- sql - Only SubQuery expressions that are top level conjuncts are allowed error