Nginx通過請求的URL做定向路由策略
阿新 • • 發佈:2019-02-15
1 2 3 4 5 6 7 8 9 10 11 |
location / {
if ( $arg__router = 10.0.0.1 ){
proxy_pass http: //10 .0.0.1:8080;
break ;
}
if ( $arg__router = 10.0.0.2 ){
proxy_pass http: //10 .0.0.2:8080;
break ;
}
proxy_pass http: //bakend ;
}
|
1 2 3 4 5 6 7 8 9 10 11 |
location / {
if ( $arg__type = app ){
proxy_pass http: //apphost ;
break ;
}
if ( $arg__type = game ){
proxy_pass http: //gamehost ;
break ;
}
proxy_pass http: //bakend ;
}
|
1 2 3 4 5 |
upstream apphost {
server 10.1.1.1:8080; #1
server 10.1.1.2:8080; #2
server 10.1.1.3:8080 backup; #3
}
|