我的Nginx配置如下:
upstream staging {
server myappstaging.somedomain.com;
}
upstream prod {
server myapp.somedomain.com:443;
}
# map to different upstream backends based on header
map $http_x_server_select $pool {
default "prod";
staging "staging";
}
server {
listen 80;
server_name myapp.mydomain.com;
location / {
proxy_pass https://$pool;
}
}
我想转发标头设置为x-server-select
的请求,而标头设置为http://myappstaging.somedomain.com
的请求
是否可以使用Nginx做到这一点?
答案 0 :(得分:1)
将方案作为变量的一部分。
例如:
map $http_x_server_select $pool {
default "https://prod";
staging "http://staging";
}
并且:
proxy_pass $pool;