[英]Pinax with gunicorn and nginx not serving static assets
hi trying to get a nginx+gunicorn+django site up and running /it works well in development mode no errors or anything.configured the nginx for deployment with the following params 嗨试图让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;
}
}
my gunicorn is being called from within the django app with: python manage.py run_gunicorn i did this after collecting my static files into .../ASUT/site_media/static only works in the dev mode tho . 我的gunicorn是从django应用程序中调用的:python manage.py run_gunicorn我在将我的静态文件收集到... / ASUT / site_media / static之后这样做只能在开发模式下工作。 i have tried substituting the location directive with 我试过替换location指令
location /static/ {
autoindex on;
access_log off;
alias /home/wakwanza/Cod/NP/ASUT/site_media/;
}
but my static assets are still not geting served all css/js/img folders arent getting seen for the normal site however for the admin section they show up ok. 但我的静态资产仍未提供服务所有css / js / img文件夹都没有被正常网站看到,但对于管理部分,他们显示确定。
sorted it by changing in settings.conf 通过在settings.conf中更改来对其进行排序
STATIC_URL = "/static/"
and nginx.conf to 和nginx.conf到
upstream app_server {
server localhost:8000 fail_timeout=0;
# For a TCP configuration:
# server 192.168.0.7:8000 fail_timeout=0;
}
server {
listen 80 default;
client_max_body_size 4G;
server_name _;
keepalive_timeout 5;
# path for static files
#root /home/wakwanza/Cod/NP/ASUT/site_media/static;
location /static/ {
autoindex on;
alias /home/wakwanza/Cod/NP/ASUT/site_media/static/;
}
location / {
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_pass_header Server;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
error_page 500 502 503 504 /500.html;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.