uWSGI虚拟主机问题

发布于 2024-10-18 09:46:02 字数 890 浏览 6 评论 0原文

uWSGI 配置

[uwsgi]
socket = /tmp/uwsgi.sock
chmod-socket = 666
processes = 1
master = true
vhost = true
no-site = true

Nginx 配置

server {
    listen       80;
    server_name  www.site1.com;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/uwsgi.sock;
        uwsgi_param UWSGI_PYHOME /var/virtualenvs/site1;
        uwsgi_param UWSGI_CHDIR /var/www/site1;
        uwsgi_param UWSGI_SCRIPT wsgi;
    }
}

server {
    listen       80;
    server_name  www.site2.com;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/uwsgi.sock;
        uwsgi_param UWSGI_PYHOME /var/virtualenvs/site2;
        uwsgi_param UWSGI_CHDIR /var/www/site2;
        uwsgi_param UWSGI_SCRIPT wsgi;
    }
}

无论我第一个访问的站点是什么,它都会卡住显示,所以如果我先转到 site2,我就看不到 site1。关于为什么 uWSGI vhost 设置似乎不起作用的任何想法?

uWSGI config

[uwsgi]
socket = /tmp/uwsgi.sock
chmod-socket = 666
processes = 1
master = true
vhost = true
no-site = true

Nginx config

server {
    listen       80;
    server_name  www.site1.com;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/uwsgi.sock;
        uwsgi_param UWSGI_PYHOME /var/virtualenvs/site1;
        uwsgi_param UWSGI_CHDIR /var/www/site1;
        uwsgi_param UWSGI_SCRIPT wsgi;
    }
}

server {
    listen       80;
    server_name  www.site2.com;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/uwsgi.sock;
        uwsgi_param UWSGI_PYHOME /var/virtualenvs/site2;
        uwsgi_param UWSGI_CHDIR /var/www/site2;
        uwsgi_param UWSGI_SCRIPT wsgi;
    }
}

Whatever site I hit first is the one it is stuck displaying, so if I goto site2 first I can't ever see site1. Any thoughts on why the uWSGI vhost setting seems not to be workin?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

青春有你 2024-10-25 09:46:02

最终的问题是使用 INI 配置文件会导致 uWSGI 在单解释器模式下运行。 XML 中完全相同的配置允许一切正常工作。 uWSGI 开发人员在未来的版本中不会出现这种情况。

The problem ending up being that using an INI config file results in uWSGI running in single interpreter mode. The exact same config in XML allows everything to work correctly. The uWSGI developer this would NOT be the case in future versions.

财迷小姐 2024-10-25 09:46:02

在这里 http://wiki.nginx.org/HttpUwsgiModuleMultipleDynamicApplications 您可以找到示例,如何通过单个上游设置多个uWSGI应用程序。

Here http://wiki.nginx.org/HttpUwsgiModuleMultipleDynamicApplications you can find example, how to setup multiple uWSGI apps, throuth a single upstream.

情话已封尘 2024-10-25 09:46:02

如果你想使用 TCP 连接或者 nginx 构建时没有 uwsgi_pass 支持:

nginx config:

location / {
    proxy_pass http://127.0.0.1:8010/;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

uwsgi ini file:

[uwsgi]
# set the http port
http = :8010

If you want to use TCP connection or nginx is built witout uwsgi_pass support:

nginx config:

location / {
    proxy_pass http://127.0.0.1:8010/;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

uwsgi ini file:

[uwsgi]
# set the http port
http = :8010
聊慰 2024-10-25 09:46:02

改用 TCP 套接字怎么样?

[uwsgi]
socket = 127.0.0.1:3031
processes = 1
master = true
vhost = true
no-site = true

nginx 配置

server {
    listen       80;
    server_name  www.site1.com;

    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:3031;
        uwsgi_param UWSGI_PYHOME /var/virtualenvs/site1;
        uwsgi_param UWSGI_CHDIR /var/www/site1;
        uwsgi_param UWSGI_SCRIPT wsgi;
    }
}

server {
    listen       80;
    server_name  www.site2.com;

    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:3031;
        uwsgi_param UWSGI_PYHOME /var/virtualenvs/site2;
        uwsgi_param UWSGI_CHDIR /var/www/site2;
        uwsgi_param UWSGI_SCRIPT wsgi;
    }
}

How about use TCP socket instead?

[uwsgi]
socket = 127.0.0.1:3031
processes = 1
master = true
vhost = true
no-site = true

nginx config

server {
    listen       80;
    server_name  www.site1.com;

    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:3031;
        uwsgi_param UWSGI_PYHOME /var/virtualenvs/site1;
        uwsgi_param UWSGI_CHDIR /var/www/site1;
        uwsgi_param UWSGI_SCRIPT wsgi;
    }
}

server {
    listen       80;
    server_name  www.site2.com;

    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:3031;
        uwsgi_param UWSGI_PYHOME /var/virtualenvs/site2;
        uwsgi_param UWSGI_CHDIR /var/www/site2;
        uwsgi_param UWSGI_SCRIPT wsgi;
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文