django+uwsgi+nginx部署實現負載均衡

在項目的文件夾下新建文件blog1.py文件

[uwsgi]
http =:8089
chdir = /home/student/project/newsite/
wsgi-file = /home/student/project/newsite/newsite/wsgi.py
processes = 4
threads = 2
stats = 127.0.0.1:9191

啟動uwsgi ———>uwsgi --ini blog.ini

在/etc/nginx/conf.d 文件夾中建立一個以.conf結尾的文件 blog.conf

upstream backend {
    server 127.0.0.1:8089;
    server 10.0.167.200:8090;
}
server {
// 定義監聽端口號
    listen  8094;
    server_name localhost www.yoyo.com;
    charset UTF-8;
    access_log  /home/student/project/newsite_access.log;
    error_log   /home/student/project/newsite_error.log;

    client_max_body_size 75M;

    location / {
        proxy_pass http://backend;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容