【发布时间】:2019-07-11 00:55:02
【问题描述】:
我的 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 标头的请求转发到 staging 到 http://myappstaging.somedomain.com 并将 prod 到 https://myapp.somedomain.com:443
Nginx 可以做到吗?
【问题讨论】: