嗨,尝试让 nginx+gunicorn+django 站点启动并运行/它在开发模式下运行良好,没有错误或任何东西。使用以下参数配置 nginx 进行部署
upstream my-backend {
server localhost:8000 fail_timeout=0;
}
server {
listen 80;
root /home/wakwanza/Cod/NP/ASUT;
keepalive_timeout 5;
location /site_media/ {
autoindex on;
access_log off;
}
location /static/ {
autoindex on;
access_log off;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE_HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-FORWARDED-PROTOCOL $scheme;
proxy_redirect off;
proxy_pass http://my-backend;
}
}
我的 gunicorn 是从 django 应用程序中调用的: python manage.py run_gunicorn 我在将我的静态文件收集到 .../ASUT/site_media/static 后执行此操作仅在开发模式下工作。我试过用 location 指令代替
location /static/ {
autoindex on;
access_log off;
alias /home/wakwanza/Cod/NP/ASUT/site_media/;
}
但是我的静态资产仍然没有得到服务,所有的 css/js/img 文件夹都没有被普通站点看到,但是对于管理部分,它们显示正常。