nginx+uwsgi+django配置

单点没有负载的nginx配置

http {

    server {

        listen 8900;

     location / { root /var/www/html; # 指定网站根目录的路径

     index index.html; # 指定默认的索引文件为index.html

}

        location /api {

            include uwsgi_params;

            uwsgi_pass 127.0.0.1:9898;

            uwsgi_read_timeout 2;

        }

    }

}

 

对应uwsgi的配置

[uwsgi]

socket = :9898

chdir = /path/to/hunter/    项目所在路径

module = app.wsgi:application   项目名称

master = true

processes = 4

threads = 2

 

如果启动了负载均衡:

Nginx配置修改为:

http {

    upstream web {

        server 192.168.1.31:9898;

        server 192.168.1.33:9898;

        server 192.168.1.144:9898;

    }

    

    server {

        listen 8900;

     location / { root /var/www/html;

     index index.html;  

}

        location /api {

            proxy_pass http://web;

        }

    }

}

Uwsgi的配置需要将socket = :9898 修改为

http=:9898

 

启动命令

uwsgi uwsgi.ini

posted @ 2023-09-21 09:24  7dao  阅读(19)  评论(0编辑  收藏  举报