本文介绍了(13:允许被拒绝)连接到上游:[nginx]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用nginx和gunicorn配置django项目。当我在nginx服务器中访问我的端口 gunicorn mysite.wsgi:application --bind = 127.0.0.1:8001 我的错误日志文件中出现以下错误。 / p>

  2014/05/30 11:59:42 [crit] 4075#0:* 6 connect()到127.0.0.1: 8001失败(13:权限被拒绝)连接上游客户端:127.0.0.1服务器:localhost请求:GET / HTTP / 1.1,上游:http://127.0.0.1:8001/,主机: localhost:8080

我的 nginx.conf 文件

  server {
listen 8080;
server_name localhost;
access_log /var/log/nginx/example.log;
error_log /var/log/nginx/example.error.log;

位置/ {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-For $ remote_addr;
proxy_set_header主机$ http_host;
}
}

在html页面中,我得到 502 Bad Gateway



我在做什么错?

解决方案

我有一个类似的问题,使Fedora 20,Nginx,Node.js和Ghost(博客)工作。原来我的问题是由于 SELinux



这应该可以解决问题:

  setsebool -P httpd_can_network_connect 1 



详细信息



我检查了SELinux日志中的错误:

  sudo cat / var / log / audit / audit.log | grep nginx | grep denied 

并发现运行以下命令可以解决我的问题:

  sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx 
sudo semodule -i mynginx.pp

参考文献:







I am working with configuring django project with nginx and gunicorn. While I am accessing my port gunicorn mysite.wsgi:application --bind=127.0.0.1:8001 in nginx server I am getting the following error in my error log file.

2014/05/30 11:59:42 [crit] 4075#0: *6 connect() to 127.0.0.1:8001 failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8001/", host: "localhost:8080"

My nginx.conf file

server {
    listen 8080;
    server_name localhost;
    access_log  /var/log/nginx/example.log;
    error_log /var/log/nginx/example.error.log;

    location / {
        proxy_pass http://127.0.0.1:8001;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $http_host;
    }
}

In the html page I am getting 502 Bad Gateway.

What mistake am I doing?

解决方案

I had a similar issue getting Fedora 20, Nginx, Node.js, and Ghost (blog) to work. It turns out my issue was due to SELinux.

This should solve the problem:

setsebool -P httpd_can_network_connect 1

Details

I checked for errors in the SELinux logs:

sudo cat /var/log/audit/audit.log | grep nginx | grep denied

And found that running the following commands fixed my issue:

sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx
sudo semodule -i mynginx.pp

References:

http://blog.frag-gustav.de/2013/07/21/nginx-selinux-me-mad/https://wiki.gentoo.org/wiki/SELinux/Tutorials/Where_to_find_SELinux_permission_denial_detailshttp://wiki.gentoo.org/wiki/SELinux/Tutorials/Managing_network_port_labelshttp://www.linuxproblems.org/wiki/Selinux

这篇关于(13:允许被拒绝)连接到上游:[nginx]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 23:46