HAProxy IPv6 configuration

Recently I finally added an IPv6 address to my loadbalancer.

I'm running the latest version of HA Proxy and I wanted to do a sort of 6to4 tunnel over my DMZ network.

So I have to configure an IPv6 address to my server and configure an extra rule to HA Proxy:

My /etc/network/interface configuration:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static

allow-hotplug eth1
iface eth1 inet static

iface eth1 inet6 static
        address 2001:.....
        netmask 64
        gateway x:x:x:x
        dns-nameservers x:x:x:x

allow-hotplug eth2
iface eth2 inet static

allow-hotplug eth3
iface eth3 inet static

After I got my IPv4 address on my eth1 interface it was time to add this to my HA Proxy configuration:

I use the "frontend" part instead of the "listen" part (if I can remember, it was because of some extra functions in the frontend part)

frontend http-proxy
        bind 2001:......:80
        option forwardfor
        option httplog
        acl is_web01 hdr(host) -i web01
        acl is_web02 hdr(host) -i web02
        use_backend httpweb01 if is_web01
        use_backend httpweb02 if is_web02
        default_backend httpcluster
        log global

Now restart/reload the HA Proxy daemon.

The netstat command now shows this line extra:

tcp6       0      0 2001:......:80 :::*                    LISTEN      16366/haproxy

Because HA Proxy is pretty smart and forwards my IPv6 web requests to my backend configuration:

backend httpcluster
        balance roundrobin
        server web01 check cookie
        server web02 check cookie
        option httpchk HEAD / HTTP/1.1\r\nHost:localhost

My backend servers are IPv4 only, so HA Proxy translates the IPv6 traffic to IPv4 on another interface.

Now HA Proxy works as an easy to configure 6to4 tunnel. :-)