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

Nginx map - use variable multiple times or use multiple variables (1 reply)

$
0
0
Hello,

We use Nginx map module to sent traffic to different upstreams based on the HTTP header:

map $http_flow $flow_upstream {
default "http://flow-dev";
prod "http://flow-prod";
test "http://flow-test";
dev "http://flow-dev";
}

location / {
proxy_read_timeout 5s;
proxy_pass $flow_upstream;
}

Now, we want to define a different timeouts to different flows:

map $http_flow $read_timeout {
default 15s;
prod 5s;
test 10s;
dev 15s;
}

location / {
proxy_read_timeout $read_timeout;
proxy_pass $flow_upstream;
}

Bunt Nginx config test show the error here:
nginx -t
nginx: [emerg] "proxy_send_timeout" directive invalid value in /etc/nginx/conf.d/flow.conf:19
nginx: configuration file /etc/nginx/nginx.conf test failed

Can we use map in such a way?

Or maybe something like this:
map $http_flow $flow_upstream $read_timeout {
default "http://flow-dev" "15s";
prod "http://flow-prod" "5s";
test "http://flow-test" "10s";
dev "http://flow-dev" "15s";
}

Thank you!

Viewing all articles
Browse latest Browse all 7229

Trending Articles



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