我根据一组标头选择了多个上游,但在添加https://github.com/GUI/nginx-upstream-dynamic-servers我的$destination
变量被解释为 URL 而不是上游。以下是代码片段:
http {
upstream LegacyService {
server my.server.location.com:443 max_fails=0 resolve;
}
upstream NewService {
server myNew.server.location.com:443 weight=100 max_fails=0 resolve;
}
...
map $http_some_header $destination {
default LegacyService;
"~marker" NewService;
}
server {
listen localhost:8080;
# lots of the usual setup
location / {
proxy_pass https://$destination;
}
}
}
这个配置给我带来了一堆错误,因为现在我的目的地被解释为 URL 而不是上游的名称:
2021/08/09 11:05:56 [error] 15326#0: *5761 no live upstreams while connecting to upstream, client: 10.1.1.5, RequestID: 6ef3b58fc95e07b083e6186df62ba15d, server: my.server.com, request: "POST / HTTP/1.1", upstream: "https://LegacyService/", host: "my.server.com"
我想了解为什么会发生这种变化,看看是否可以采取什么措施。我是否误读了错误消息?