Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

proxy_pass help

$
0
0
Hi Guy's.

My current config currently looks up id's from a flat file, takes that id number and then passes traffic to the relevant cluster of servers based on that id number.

Specifics of my config file:

upstream cluster01 {
least_conn;
server 10.105.137.13 slow_start=30s;
server 10.105.137.14 slow_start=30s;
server 10.105.137.15 slow_start=30s;
zone cluster01 64k;
}

upstream cluster02 {
least_conn;
server 10.105.137.39 slow_start=30s down;
server 10.105.137.40 slow_start=30s down;
server 10.105.137.42 slow_start=30s down;
zone cluster02 64k;
}


map $siteid $clusterid {
default 1;
include conf.d/cluster.mapping;
}

proxy_pass http://cluster0$clusterid; # detected cluster id is used here



What i would like to do is pass traffic to clusters with different naming conventions but i'm not sure how. The problem i have is that the cluster names don't actually match the ID numbers so i'd like to be able to use any cluster name i want and only look at the specific ID number when i proxy_pass.

I'd like to be able to write a config to look a little something like this:

upstream cluster01_id6 {
least_conn;
server 10.105.137.13 slow_start=30s;
server 10.105.137.14 slow_start=30s;
server 10.105.137.15 slow_start=30s;
zone cluster01_id6 64k;
}

upstream cluster02_id7 {
least_conn;
server 10.105.137.39 slow_start=30s down;
server 10.105.137.40 slow_start=30s down;
server 10.105.137.42 slow_start=30s down;
zone cluster02_id7 64k;
}

map $siteid $clusterid {
default 1;
include conf.d/cluster.mapping;
}

proxy_pass http://*_id$clusterid; # detected cluster id is used here

I understand that the '*_id' syntax is incorrect but this is how i'd like to run it..... So the name of the zone is irrelevant and proxy_pass is just reading the _id? section which directly relates to the id in cluster.mapping but i can name my zones whatever i like. This means my clusters are named correctly and i can name them whatever i want. : )

I hope that's clear enough. If i can't it means i'll have to rename all my clusters so the id's match which i don't really want to do.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



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