我有一台安装了nginx的centos服务器,我将在其中加载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"';
}
在这一点上,当我为/ home / ec2-user / test / endpoint / website / static /下的所有资源启动gunicorn和nginx seervic时,我收到403禁止访问错误。 我尝试:
sudo chmod -R 777 <Path to static>
也尝试过
sudo chown -R nginx:nginx <path to static>
但错误403仍然存在
我该如何解决此问题?
预先感谢
但问题仍然存在