Quantcast
Channel: Nginx Forum - Nginx Mailing List - English
Viewing all articles
Browse latest Browse all 7229

Dynamic upstream proxy_pass (2 replies)

$
0
0
I'm trying to set upstream names by variables, but nginx recognizes variables as hostnames, not upstream names.

For example:
map $cookie_backend $proxy_host {
default 'backend1';
'1' 'backend2';
}
... ... ...
upstream backend1 {
server backend123:8080;
server backend124:8080;
}
... ... ...
upstream backend2 {
server backend223:8080;
server backend224:8080;
}
... ... ...
location / {
proxy_pass http://$proxy_host;
}

nginx returns error message:
2014/04/09 14:19:51 [error] 1085#0: *1128620 backend1 could not be resolved (3: Host not found) while sending to client, client: 192.168.1.145, server: localhost, request: "GET / HTTP/1.1", host: "localhost"

Viewing all articles
Browse latest Browse all 7229

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>