Answer the question
In order to leave comments, you need to log in
Django 1.9 static on production server?
Hello!
I deployed my Django blog on the server using the nginx + gunicorn bundle.
The page at the specified address is displayed, but there is trouble with static, then the nginx config:
server {
listen 80;
server_name darkpy.com;
access_log /var/log/nginx/example.log;
Вариант 1
#location /static/ {
# root /root/blog/myblog/blog/;
# expires 30d;
# }
Вариант 2, текущий
location ~* ^.+\.(jpg|jpeg|gif|png|ico|txt|css|js)$ {
root /root/blog/myblog/_media;
}
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
80.76.103.3 - - [19/Jan/2016:22:08:16 +0300] "GET /static/blog/css/bootstrap.css HTTP/1.1" 403 208 "http://62.109.3.37/" "Mozilla/5.0 (X11; Linux x86_$
80.76.103.3 - - [19/Jan/2016:22:08:16 +0300] "GET /static/blog/style.css HTTP/1.1" 403 208 "http://62.109.3.37/" "Mozilla/5.0 (X11; Linux x86_64) Appl$
Answer the question
In order to leave comments, you need to log in
Try to write the path to the static like this:
location /static/ {
alias /home/.../django_project/static/;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question