nginx serving django static and media files 403 forbidden -


first try find solution other questions, can't working me, create new one.

the detail below:

1 try change user in nginx.conf

#user www-data; user me; worker_processes 4; pid /run/nginx.pid; .... 

2 add , link conf on sites-available , sites-enabled

server {     add_header access-control-allow-origin *.mysite.com;     add_header access-control-allow-headers x-requested-with;     add_header access-control-allow-methods get,post,options;     listen  80;     server_name mysite.com;     access_log /var/log/nginx/hitek.access.log;     error_log /var/log/nginx/hitek.error.log;      location / {         proxy_pass http://127.0.0.1:8010;         proxy_set_header host $host;         proxy_set_header x-real-ip $remote_addr;         proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;     }      location ~ ^/media/  {         #alias /var/www/html/mysite/media;         alias /home/me/website/mysite/media;         #alias /home/www-data/website/website/mysite/media;         expires 1h;         access_log off;     }      location ~ ^/static/ {         #alias /var/www/html/mysite/collected_static;         alias /home/me/website/mysite/collected_static;         #alias /home/www-data/website/website/mysite/collected_static;         expires 1h;         access_log off;         include /etc/nginx/mime.types;     } } 

you can see 4 line comment, try copy collected_static , media folders place ,but failure. of course change permission on folders.

~/website$ ls -alt drwxrwxrwx 8 me me 4096 sep 11 14:43 mysite drwxr-xr-x 6 me me 4096 sep  8 14:30 .. drwxrwxrwx 4 me me 4096 sep  7 11:41 . 

who can answer it? thank.

add slash end of path. otherwise, nginx not able find files.

alias /home/me/website/mysite/media/; 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -