Centos nginx + django + gunicorn 403 запрещено - PullRequest
0 голосов
/ 27 июня 2018

У меня есть сервер Centos с установленным nginx, где я могу загрузить приложение django. После установки python34, nginx, django и gunicorn я настраиваю файл nginx.conf следующим образом:

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile            on;
tcp_nopush          on;
tcp_nodelay         on;
keepalive_timeout   65;
types_hash_max_size 2048;

include             /etc/nginx/mime.types;
default_type        application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;

index   index.html index.htm;

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  54.17X.2XX.11X;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

location /static/ {
    #alias /opt/cath/static/;
    alias /home/ec2-user/test/endpoint/website/static/;
} 

    location / {
    proxy_pass http://127.0.0.1:8000/site;
    proxy_set_header X-Forwarded-Host $server_name;
    proxy_set_header X-Real-IP $remote_addr;
    add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
    }

хорошо, в этот момент, когда я запускаю gunicorn и nginx seervic для всех ресурсов в / home / ec2-user / test / endpoint / website / static /, я получаю ошибку 403 запрещенного доступа. Я пытаюсь с:

sudo chmod -R 777 <Path to static>

также пробовал с

sudo chown -R nginx:nginx <path to static>

, но ошибка 403 сохраняется

Как я могу решить эту проблему?

Заранее спасибо

но проблема сохраняется

...