Pinax avec Gunicorn et Nginx ne servant pas d'actifs statiques
Question
Bonjour Essayer d'obtenir un site Nginx + Guncann + Django Up and Shuning / Il fonctionne bien en mode de développement Aucune erreur ou quoi que ce soit.Configuré le NGinx pour le déploiement avec les params suivants
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;
}
}
Mon arminorn est appelé à partir de l'application Django avec: python gérer.py run_gunicorn Je l'ai fait après avoir collecté mes fichiers statiques dans ... / astub / site_media / statique ne fonctionne que dans le mode DEV en mode. J'ai essayé de substituer la directive de localisation avec
location /static/ {
autoindex on;
access_log off;
alias /home/wakwanza/Cod/NP/ASUT/site_media/;
}
Mais mes actifs statiques ne sont toujours pas servis servis tous les dossiers CSS / JS / IMG ne sont pas disponibles pour le site normal, cependant, pour la section admin qu'ils apparaissent OK.
La solution
sorted it by changing in settings.conf
STATIC_URL = "/static/"
and nginx.conf to
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;
}