当我没有在我的url中指定我的端口号时,静态文件不会在这种情况下加载。它在xyz.com上工作正常:8000所有静态文件都加载了但是当我使用xyz.com时,它不会加载任何静态文件。我使用nginx服务器。
这是我的nginx配置
server {
listen 80;
server_name santhals.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/ubuntu/santhals/myapp/;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
字符串
2条答案
按热度按时间kkbh8khc1#
参考这个可以帮助吗?
Nginx serve static file and got 403 forbidden
我偷看了你的工作(对不起,但我不能帮助它)和浏览器说403禁止。
ih99xse12#
您的
Nginx
插件看起来很好,如果没有权限和访问问题,它应该可以工作。有几件事要检查:
1.确保
django.contrib.staticfiles
包含在settings.py
文件的INSTALLED_APPS
中。1.确保在
settings.py
文件中正确设置了STATIC_URL
和STATIC_ROOT
变量。通常,它们应该指向位于项目根目录中的static
目录。1.确保在部署应用程序之前运行
python manage.py collectstatic