
我有許多上游,我根據一組標頭從中選擇,但在添加後發現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"
我想了解為什麼會發生這種變化,並看看是否有什麼可以做的。我是否誤讀了錯誤訊息?