Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4720

Dynamic source address

$
0
0

Hi all!

For avoiding the problem of port exhaustion when connecting to upstream servers I have configured several IPs in my HAProxy machine. My intention is HAProxy to use those IPs as source addresses when connecting to the upstream servers (outgoing connections).

For selecting the source address for outgoing connections I have found the “source” option. The problem is that there is not an easy way of using several source addresses using this option.

The only way I have found for doing this is to duplicate the server definitions, using a different source address for each of them. For example, for 2 real servers (app1 and app2) and 3 outgoing IPs:

backend my-backend
        balance leastconn
        server app1_src1 app1.test.com source 192.168.1.1
        server app1_src2 app1.test.com source 192.168.1.2
        server app1_src3 app1.test.com source 192.168.1.3
        server app2_src1 app2.test.com source 192.168.1.1
        server app2_src2 app2.test.com source 192.168.1.2
        server app2_src3 app2.test.com source 192.168.1.3

As you can see, I have had to create 6 “virtual” servers in my backend, one for each application-sourceIP combination.

Although this solutions works, it is not ideal, as we are not balancing the load properly between the two real servers, but on the 6 “virtual/artificial” servers, combinations of real server and source IP. Also, disabling a specific real server from the backend is more complex, because we need to disable all the possible combinations of that server.

Ideally, I would like to use dynamic variables or converters in the “source” option. For example:

backend my-backend
        balance leastconn
        source %[rand(3),map(myips.map)]
        server app1 app1.test.com
        server app2 app2.test.com

Unfortunately, it seems that the “source” option does not expand a logformat string, so we cannot use variables or converters with it.

Is there a better way of doing this?

Regards.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4720

Trending Articles



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