nginx配置+uwsgi+负载均衡配置

nginx静态文件配置

location /static{
            alias  /var/www/myApp/static;
        }
sudo mkdir -vp /var/www/myApp/static/
sudo chmod 777 /var/www/myApp/static/

#工程目录settings下配置静态文件
STATIC_ROOT = '/var/www/myApp/static'
STATIC_URL = '/static/'

#迁移静态文件
python manage.py collectstatic

#settings目录中
DEBUG = Flase
ALLOW_HOST = ['*']

nginx + 反向代理 + runserver

location / {
           proxy_pass http://www.pipixia957.cn:8000;  #反向代理设置
           proxy_set_header X-real-ip $remote_addr;
           proxy_set_header Host $http_host;
        }


[uwsgi]
http=0.0.0.0:8000
chdir=/home/ubuntu/pro/project
wsgi-file=project/wsgi.py
processes=2
threads=2
master=True
pidfile=uwsgi.pid
daemonize=uwsgi.log

runserver启动
#访问不需要加端口

nginx + uwsgi启动

 location / {
            include uwsgi_params;
            uwsgi_pass www.pipixia957.cn:8000;
        }
 
[uwsgi]
socket=0.0.0.0:8000
chdir=/home/ubuntu/pro/project
wsgi-file=project/wsgi.py
processes=2
threads=2
master=True
pidfile=uwsgi.pid
daemonize=uwsgi.log

#访问不需要再加端口

nginx + 负载均衡

upstream mycom{
    ip_hash;
    server 10.11.0.1:8000;  #负载均衡服务器群
    server 10.11.0.1:8000;
    server 10.11.0.1:8000  down;
}

location / {   
            include uwsgi_params;
            uwsgi_pass mycom; #连接负载均衡服务器
        }
posted @ 2018-06-24 10:58  诚实善良小郎君  阅读(309)  评论(0编辑  收藏  举报