使用gunicorn和nginx服务多个站点?

2024-04-19 06:57:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用gunicorn和nginx同时提供Django和烧瓶站点。Django网站目前在example.com网站,我想在myapp.example.com网站. 在

对于Django站点,我的nginx配置文件如下:

cat /etc/nginx/sites-available/example.com 
server {
    listen 80;
    server_name example.com;

    location /static {
        alias /home/me/sites/example.com/static;
    }

    location / {
        proxy_set_header Host $host;
        proxy_pass http://unix:/tmp/example.com.socket;
    }
}

我还有另一个Flask站点的nginx配置文件:

^{pr2}$

我很确定要更改proxy_pass变量,但不确定应该将其更改为什么。在

我的gunicorn文件目前如下:

description "Gunicorn server for example.com"

start on net-device-up
stop on shutdown

respawn

setuid me
chdir /home/rowan/sites/example.com/source

exec ../virtualenv/bin/gunicorn \
    --bind unix:/tmp/example.com.socket \
    example.com.wsgi:application

我需要第二个烧瓶站点的gunicorn配置文件吗?然后我会把它放入/etc/init/并通过sudo start gunicorn-myapp.example.com命令启动?在


Tags: djangocomserver烧瓶站点网站example配置文件