python - Nginx 和 uWSGI : Connection refused and 502 Bad Gateway error

标签 python nginx uwsgi

尝试在 Ubuntu 13.10 上设置 Nginx 和 uWSGI。

当我尝试访问该网站时,我得到的只是“502 Bad Gateway”。

运行 apt-get install nginx uwsgi uwsgi-plugin-python3 来安装 nginx/uwsgi。

/etc/nginx/sites-enabled/webpage.com:

server {
        listen          80;
        server_name     webpage.com;
        access_log /var/log/nginx/webpage.com_access.log;
        error_log /var/log/nginx/webpage.com_error.log;


        location / {
            uwsgi_pass      /var/run/webpage.com.uwsgi.socket;
            include         uwsgi_params;
            uwsgi_param     Host $host;
            uwsgi_param     X-Real-IP $remote_addr;
            uwsgi_param     UWSGI_SCHEME $scheme;
            uwsgi_param     SERVER_SOFTWARE nginx/$nginx_version;     
        }
}

/etc/uwsgi/apps-enabled/webpage.com

[uwsgi]
vhost = true
plugin = python3
socket = /tmp/webpage.com.sock
master = true
enable-threads = true
processes = 2
home = /var/www/webpage.com/env
wsgi-file = /var/www/webpage.com/env/hello.py
virtualenv = /var/www/webpage.com/env
chdir = /var/www/webpage.com/env
touch-reload = /var/www/webpage.com/reload

/var/log/nginx/webpage.com_error.log

2014/01/17 16:28:58 [error] 25073#0: *13 connect() to unix:///var/run/webpage.com.uwsgi.socket failed (111: Connection refused) while connecting to upstream, client: 83.109.132.224, server: webpage.com, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///var/run/webpage.com.uwsgi.socket:", host: "webpage.com"

hello.py 只是一个简单的 hello world 应用程序。

已经为此苦苦挣扎了几个小时......现在我需要帮助:)

最佳答案

查看此处发布的配置文件,您将 nginx 中的套接字引用为:

uwsgi_pass      /var/run/webpage.com.uwsgi.socket;

在 uwsgi 中作为

socket = /tmp/webpage.com.sock

关于python - Nginx 和 uWSGI : Connection refused and 502 Bad Gateway error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21190394/

相关文章:

ruby-on-rails - 发送重定向到特定端口

python - 在生产环境中在 Windows 上部署 Flask

python - ZMQ python 套接字从上下文捕获异常

python - raw_input 的奇怪重定向效果

python - 如何在 Tkinter 文本小部件绑定(bind)后在 Tkinter 文本小部件中绑定(bind)自身事件?

在 Debian 7 下禁止 nginx 403

python - 在 m1 Monterey 上安装 uWSGI 失败并出现 python 3.10.0

python - uWSGI Workers 写入同一个 JSON 文件

python - Python 中奇怪的比较

python - PyGTK窗口在创建时崩溃