2012-01-26 7 views
0

ハイテクサービスを提供し、実行していない/それは、開発モードエラーなしでうまく機能するか、次のparamsを展開するためのnginxをanything.configuredPinaxはnginxの+ gunicorn + Djangoのサイトのアップを取得しようとしている静的な資産

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は、私が唯一のdevのモードカントーで動作 .../ASUT/site_media /静的に私の静的ファイルを収集した後にこれをやった をrun_gunicorn manage.pyの。 私は

location /static/ { 
    autoindex on; 
     access_log off; 
alias /home/wakwanza/Cod/NP/ASUT/site_media/; 
    } 

と場所ディレクティブを代入しようとしているが、私の静的な資産は、まだすべてのCSS/JS/IMGフォルダは、彼らはOK表示管理セクションのためしかし、通常のサイトで見られなっアレント務めgetingされていません。

答えて

2

がsettings.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; 

} 
+0

おかげ

STATIC_URL = "/static/" 

とnginx.confを変更することで、それをソートし、これは私の静的ファイルで404エラーを解決しました。 –

関連する問題