Nginx代理传递给本地主机Gunicorn意外返回50x错误

我有一个非常基本的设置与nginx安装在运行在gunicorn服务器上的django应用程序。 gunicorn conf很简单,下面是:

exec gunicorn myapp.wsgi:application \ --workers 5 --reload 

我已经设置了nginx服务器,将默认服务器上的所有传入stream量proxy_pass设置为127.0.0.1:8000。 但是,当我到服务器的IP地址,我看到默认的nginx 404屏幕。 所以我假设stream量是由nginx服务器传递的代理,但不知何故没有正确路由,并没有回应,这迫使nginx返回404。我究竟是在这里做gunicorn或nginxconfiguration错误? 作为参考,下面是我的完整的nginx.conf文件:

 user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /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; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; include /etc/nginx/sites-available/* upstream app_server { server 127.0.0.1:8000 fail_timeout=0; } server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { proxy_pass http://127.0.0.1:8000; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } 

编辑:经过更仔细的调查在这个设置的错误消息,我意识到这不是一个404,它实际上是一个50倍,所以肯定是在两个服务相互沟通的方式错了。 去单独的gunicorn端点生产django应用程序没有问题。 在添加proxy_pass参数之前,要进入默认的nginx splace屏幕。 任何帮助,我错过了什么。 谢谢

解决了我自己的问题。 基本上,对于运行nginx的基于fedora的解决scheme,您必须打开对所有非root用户的上游连接访问权限。 你可以用这个命令来做到这一点

 setsebool -P httpd_can_network_connect 1 

显然以root身份运行。 进一步的信息可以在这个其他问题上find: https : //stackoverflow.com/questions/23948527/13-permission-denied-while-connecting-to-upstreamnginx