配置负载均衡池
#Demo1负载均衡池
upstream bolg_pool{
server 127.0.0.1:8081;
}
#Demo2负载均衡池
upstream img_pool{
server 127.0.0.1:8022;
}
Demo1端口转发
server {
listen 80; #拦截端口
server_name bolg.xxxxx.com; #域名配置
access_log logs/bolg.log;
error_log logs/bolg.error;
#将所有请求转发给blog_pool池的应用处理
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://blog_pool; #如果是ssl更改成https
}
}
Demo2端口转发
server {
listen 80; #拦截端口
server_name img.xxxxx.com; #域名配置
access_log logs/img.log;
error_log logs/img.error;
#将所有请求转发给img_pool池的应用处理
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://img_pool;#如果是ssl更改成https
}
}