Change the value of a map file entry.
set map to find an entry in a map file and replace its value.
Assume that you have a map file named /etc/hapee-2.3/routes.map with the following contents where the first column contains the keys and the second contains the values:
/cart/ cart_api /reviews/ reviews_api
In the HAProxy Enterprise configuration, we reference this map file on a
use_backend line with the
map_beg fetch method. This tells the load balancer to choose the backend from the map file by matching the beginning of the requested URL path with a key in the file:
frontend fe_main bind :80 use_backend %[path,map_beg(/etc/hapee-2.3/routes.map,be_servers)]
show mapscommand to list map files and their unique IDs. Here, the map file /etc/hapee-2.3/routes.map has an ID of 0:
$ echo "show map" | socat stdio tcp4-connect:127.0.0.1:9999 # id (file) description 0 (/etc/hapee-2.3/routes.map) pattern loaded from file '/etc/hapee-2.3/routes.map' used by map at file '/etc/hapee-2.3/hapee-lb.cfg' line 61
Pass the map file's unique ID to
show mapto display entries in the file:
$ echo "show map #0" | socat stdio tcp4-connect:127.0.0.1:9999 0x563bbeeee160 /cart/ cart_api 0x563bbeeee1a0 /reviews/ reviews_api
Pass to the
set mapcommand the map's ID, the key in the map to find, and a value that should replace the existing value.
Alternatively, use the map file's path instead of its ID.
In the example below, we replace the value cart_api with web_servers for the key /cart/:
$ echo "set map #0 /cart/ web_servers" | socat stdio tcp4-connect:127.0.0.1:9999
show mapagain to see that the value has been replaced:
$ echo "show map #0" | socat stdio tcp4-connect:127.0.0.1:9999 0x563bbeeee160 /cart/ web_servers 0x563bbeeee1a0 /reviews/ reviews_api
Next upset maxconn frontend