我有一个 Nginx,后面有 2 个服务器(90% 和 10% 负载平衡),我在其中发送请求。配置如下:
upstream https://upstream-stage.infra.com/ {
ip_hash;
server oldserver-stage.infra.com weight=9 max_fails=3 fail_timeout=30s;
server newserver-stage.infra.com weight=1 max_fails=3 fail_timeout=30s;
}
server {
server_name upstream-nginx-stage.infra.com www.upstream-nginx-stage.infra.com;
return 301 https://upstream-nginx-stage.infra.com$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/wild.infra.com.crt;
ssl_certificate_key /etc/nginx/ssl/wild.infra.com.key;
server_name www.upstream-nginx-stage.infra.com;
return 301 https://upstream-nginx-stage.infra.com$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/wild.infra.com.crt;
ssl_certificate_key /etc/nginx/ssl/wild.infra.com.key;
server_name upstream-nginx-stage.infra.com;
location / {
proxy_pass https://upstream-stage.infra.com/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
我的问题是-如何在此配置中设置例外以始终发送请求如下,而无需任何负载平衡:
upstream-nginx-stage.infra.com/exception1PDF/... => oldserver-stage.infra.com
upstream-nginx-stage.infra.com/exception2/... => newserver-stage.infra.com
upstream-nginx-stage.infra.com/someAPIrequest#/... => APIPublicApp.azurewebsites.net (standalone and completelly different site)