一、IP地址反向代理-负载均衡配置
upstream supermarket_api {
server 47.105.*.74:8002 weight=1;
server 39.108.*.186:8800 weight=4;
server 127.0.0.1:8002 weight=5;
}
server {
listen 8880;
server_name 47.115.*.11;
location /app{
proxy_pass http://supermarket_api;
proxy_set_header Host $host;
}
}
注:为了安全性,部分IP用*号做了代替
二、域名反向代理-负载均衡配置
upstream supermarket_server{
# AC-ECS
server 47.105.146.*:8002 weight=1;
# ECS-test
server 39.108.*.186:8800 weight=5;
# ECS-backup-prod
server 47.115.*.11:8002 weight=5;
}
server{
listen 80;
server_name test.com www.test.com;
location /{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:6002;
}
# 访问服务器文件(图片)
location /files{
proxy_pass http://47.115.*.11:8002;
proxy_set_header Host $host;
}
# 将文件(图片)上传到指定一台服务器
location /app/files/upload{
proxy_pass http://47.115.*.11:8002;
proxy_set_header Host $host;
}
location /manage/files/upload{
proxy_pass http://47.115.*.11:8002;
proxy_set_header Host $host;
}
location /login{
proxy_pass http://supermarket_server;
proxy_set_header Host $host;
}
location /manage{
proxy_pass http://supermarket_server;
proxy_set_header Host $host;
}
location /app{
proxy_pass http://supermarket_server;
proxy_set_header Host $host;
}
}
server{
listen 6002;
server_name 127.0.0.1;
root /data/pc/supermarket/dist;
location /{
root /data/pc/supermarket/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
location /home{
rewrite .* /index.html break;
root /data/pc/supermarket/dist;
}
}
网友评论