我一直在試圖調試這幾個小時,我不知道還有什麼要檢查。我的問題是,Nginx不服務Django靜態文件。訪問靜態文件導致錯誤403 Forbidden。Nginx的/ Django的:訪問靜態文件的結果403禁止
從Nginx的錯誤日誌確切的錯誤是:
2013/02/11 05:42:13 [error] 22526#0: *29 open() "/home/mydomain/public_html/test2/src/bootstrap.css" failed (13: Permission denied), client: XXX.XXX.XX.XX, server: mydomain.com, request: "GET /src/bootstrap.css HTTP/1.1", host: "www.mydomain.com"
這裏是我的nginx的配置文件:
server {
listen XX.XX.X.XXX:80;
server_name mydomain.com;
root /home/mydomain/public_html/test2/app;
# serve directly - analogous for static/staticfiles
location /media/ {
# if asset versioning is used
if ($query_string) {
expires max;
}
}
location /admin/media/ {
# this changes depending on your python version
root /home/mydomain/public_html/test2/lib/python2.7/site-packages/django/contrib;
}
location /src/ {
autoindex on;
root /home/mydomain/public_html/test2;
}
location/{
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 10;
proxy_read_timeout 10;
proxy_pass http://localhost:8000/;
}
# what to serve if upstream is not available or crashes
error_page 500 502 503 504 /media/50x.html;
}
靜態文件存儲在/home/mydomain/public_html/test2/src
。
我試過chown mydomain.mydomain -R *
和chmod 755 /home/mydomain -R *
沒有任何影響。
嗨,你能解釋一下這些配置究竟發生了什麼? – 2016-02-11 23:16:18