[英]Centos nginx + django + gunicorn 403 forbidden
I have a centos server with nginx installed where i would to load a django app.我有一个安装了 nginx 的 centos 服务器,我将在其中加载 django 应用程序。 After install python34, nginx, django and gunicorn i configure nginx.conf file like this:安装 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"';
}
well at this point, when i start gunicorn and nginx seervic for all the resource under /home/ec2-user/test/endpoint/website/static/ i receive the 403 forbidden access error.此时,当我为 /home/ec2-user/test/endpoint/website/static/ 下的所有资源启动 gunicorn 和 nginx seervic 时,我收到 403 禁止访问错误。 I try with:我尝试:
sudo chmod -R 777 <Path to static>
also tried with也试过
sudo chown -R nginx:nginx <path to static>
but error 403 persist但错误 403 仍然存在
How can i resolve this issue?我该如何解决这个问题?
Thanks in advance提前致谢
but the problem persist但问题仍然存在
i think it is related to SELinux you can disable it by:我认为它与 SELinux 有关,您可以通过以下方式禁用它:
nano /etc/selinux/config change the value of SELINUX to disabled nano /etc/selinux/config 将 SELINUX 的值更改为禁用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.