nginx

岁月如歌 2020-07-27

server 配制

server {
listen 80;
server_name localhost;
# charset koi8-r;
# access_log logs/host.access.log main;
location / { # 每个location 相当 于一个url
# 包含uwsgi的请求参数
include uwsgi_params;
# 转交请求给uwsgi
uwsgi_pass 127.0.0.1:8000
}

location /static {
    # 指定静态文件存放的目录
    alias /xxx/xxx/static/;

}
#location / {
    # nginx 转发请求给另外地址
   # proxy_pass http://172.16.179.131:80

}

}

nginx 负载均衡实现

upstream xxx { # xxx 是自己启的名字
server 127.0.0.1:8000;
server 127.0.0.1:80801
}
server {
...
...
location / {
# 包含uwsgi的请求参数
include uwsgi_params;
# 转交请求给uwsgi
uwsgi_pass xxx # upstream 中 自己启的名字
}

}

相关推荐