Django + uwsgi + nginx + CentOS 7 : 在8001端口拒绝连接

0 人关注

Django + uwsgi + nginx + CentOS 7 : 在8001端口拒绝连接

I get http 520 error when I tried to go to http://domain.com:8000

nginx.conf

    upstream django {
        # connect to this socket
        # server unix:///tmp/uwsgi.sock;    # for a file socket
        server 127.0.0.1:8001;      # for a web port socket
    server {
        # the port your site will be served on
        listen      8000;
        # the domain name it will serve for
        server_name domain.com;   # substitute your machine's IP address or FQDN
        #root /home/mysite;
        charset     utf-8;
        #Max upload size
        client_max_body_size 75M;   # adjust to taste
        # Finally, send all non-media requests to the Django server.
        location / {
            uwsgi_pass  django;
            include     /home/mysite/uwsgi_params; # or the uwsgi_params you installed manually

/var/log/nginx/error.log上的错误信息

2015/04/09 12:28:07 [error] 23235#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 118.131.206.235, server: domain.com, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:8001", host: "domain.com:8000"
2015/04/09 12:28:08 [error] 23235#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 118.131.206.235, server: domain.com, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://127.0.0.1:8001", host: "domain.com:8000"

我已经尝试了所有的方法,但找不到任何线索,它给我的是http 502错误。

1 个评论
你的uWSGI服务器真的在运行吗?它是否绑定在8001端口上?
python
linux
django
nginx
uwsgi
Jake
Jake
发布于 2015-04-09
1 个回答
Dmitry Shihovtsev
Dmitry Shihovtsev
发布于 2015-04-10
已采纳
0 人赞同

SELinux可能会默认阻止这种类型的连接。

你需要检查日志文件/var/log/audit/audit.log以确定这一点。