Questions Re: Nomad, Fabio, Apache Tutorial

Hi All,

I recently setup a local Consul/Nomad cluster using Vagrant - one server, two clients. I’ve assigned different private IP addresses to each of them (see Vagrantfile, below).

LINUX_BASE_BOX = "bento/ubuntu-18.04"

Vagrant.configure("2") do |config|

    config.vm.define "server" do |server|
		server.vm.box = LINUX_BASE_BOX
		server.vm.hostname = "server"
		server.vm.network "private_network", ip: "172.20.20.10"
		server.vm.network "forwarded_port", guest: 8500, host: 8500     
		server.vm.network "forwarded_port", guest: 4646, host: 4646     
		server = configureVirtualBox server
		server = configureProvisioners server
    end

	1.upto(2) do |n|
        config.vm.define "client#{n}" do |client|
            client.vm.box = LINUX_BASE_BOX
            client.vm.hostname = "client#{n}"
            client.vm.network "private_network", ip: "172.20.20.%d" % [20 + n]
            client = configureVirtualBox client
            client = configureProvisioners client
        end
	end

end

def configureVirtualBox(config, cpus: "2", memory: "2048")
	config.vm.provider "virtualbox" do |v|
		v.customize ["modifyvm", :id, "--cableconnected1", "on", "--audio", "none"]
		v.memory = memory
		v.cpus = cpus
	end

	return config
end

def configureProvisioners(config)
    config.vagrant.plugins = "vagrant-docker-compose"
    config.vm.provision :docker

    config.vm.provision "ansible" do |ansible|
        ansible.playbook = "../playbooks/hashistack.yml"
    end

	return config
end

Following this I tried the official tutorial on load balancing with Fabio. Apache servers started successfully, but were all bound to the same IP address: 10.0.2.15 (with different ports, of course). This address also happens to be the default eth0 address of all VMs, and apparently cannot be changed.

On to my questions.

  1. How can I get the Apache instances to be bound using the custom private IP addresses of the client VMs they are running on? Is this a good idea, or am I missing something?
  2. When I access Fabio using any client IP (e.g. http://172.20.20.21:9999/) the requests sometimes fail. Does this have something to do with the fact that all Apache instances are bound to the same IP address? I found the following in Fabio logs:
2022/02/25 11:05:31 [INFO] Version 1.5.15 starting
2022/02/25 11:05:31 [INFO] Go runtime is go1.15.5
2022/02/25 11:05:31 [INFO] Running fabio as UID=0 EUID=0 GID=0
2022/02/25 11:05:31 [WARN] 

	************************************************************
	You are running fabio as root without the '-insecure' flag
	This will stop working with fabio 1.7!
	************************************************************

2022/02/25 11:05:31 [INFO] Metrics disabled
2022/02/25 11:05:31 [INFO] Setting GOGC=100
2022/02/25 11:05:31 [INFO] Setting GOMAXPROCS=2
2022/02/25 11:05:31 [INFO] Running fabio as UID=0 EUID=0 GID=0
2022/02/25 11:05:31 [WARN] 

	************************************************************
	You are running fabio as root without the '-insecure' flag
	This will stop working with fabio 1.7!
	************************************************************

2022/02/25 11:05:31 [INFO] consul: Connecting to "localhost:8500" in datacenter "dc1"
2022/02/25 11:05:31 [INFO] Admin server access mode "rw"
2022/02/25 11:05:31 [INFO] Admin server listening on ":9998"
2022/02/25 11:05:31 [INFO] Waiting for first routing table
2022/02/25 11:05:31 [INFO] consul: Using dynamic routes
2022/02/25 11:05:31 [INFO] consul: Using tag prefix "urlprefix-"
2022/02/25 11:05:31 [INFO] consul: Watching KV path "/fabio/config"
2022/02/25 11:05:31 [INFO] consul: Watching KV path "/fabio/noroute.html"
2022/02/25 11:05:31 [INFO] HTTP proxy listening on :9999
2022/02/25 11:05:31 [INFO] Running fabio as UID=0 EUID=0 GID=0
2022/02/25 11:05:31 [WARN] 

	************************************************************
	You are running fabio as root without the '-insecure' flag
	This will stop working with fabio 1.7!
	************************************************************

2022/02/25 11:05:31 [INFO] Access logging disabled
2022/02/25 11:05:31 [INFO] Using routing strategy "rnd"
2022/02/25 11:05:31 [INFO] Using route matching "prefix"
2022/02/25 11:05:31 [INFO] consul: Registered fabio as "fabio"
2022/02/25 11:05:31 [INFO] consul: Registered fabio with id "fabio-client2-9998"
2022/02/25 11:05:31 [INFO] consul: Registered fabio with address "10.0.2.15"
2022/02/25 11:05:31 [INFO] consul: Registered fabio with tags ""
2022/02/25 11:05:31 [INFO] consul: Registered fabio with check &{CheckID:fabio-client2-9998-ttl Name: Args:[] DockerContainerID: Shell: Interval: Timeout: TTL:15s HTTP: Header:map[] Method: Body: TCP: Status: Notes: TLSSkipVerify:false GRPC: GRPCUseTLS:false AliasNode: AliasService: SuccessBeforePassing:0 FailuresBeforeCritical:0 DeregisterCriticalServiceAfter:1m0s}
2022/02/25 11:05:31 [INFO] consul: Registered fabio with check &{CheckID: Name: Args:[] DockerContainerID: Shell: Interval:1s Timeout:3s TTL: HTTP:http://[10.0.2.15]:9998/health Header:map[] Method: Body: TCP: Status: Notes: TLSSkipVerify:false GRPC: GRPCUseTLS:false AliasNode: AliasService: SuccessBeforePassing:0 FailuresBeforeCritical:0 DeregisterCriticalServiceAfter:}
2022/02/25 11:05:31 [INFO] Config updates
+ route add apache-webserver / http://10.0.2.15:22917/
+ route add apache-webserver / http://10.0.2.15:22386/
+ route add apache-webserver / http://10.0.2.15:21257/
2022/02/25 11:11:15 [ERROR] dial tcp 10.0.2.15:22386: connect: connection refused
2022/02/25 11:11:22 [ERROR] dial tcp 10.0.2.15:21257: connect: connection refused
2022/02/25 11:12:47 [ERROR] dial tcp 10.0.2.15:22386: connect: connection refused
2022/02/25 11:14:16 [ERROR] dial tcp 10.0.2.15:22386: connect: connection refused
2022/02/25 11:14:20 [ERROR] dial tcp 10.0.2.15:21257: connect: connection refused
2022/02/25 11:14:24 [ERROR] dial tcp 10.0.2.15:21257: connect: connection refused
2022/02/25 11:14:25 [ERROR] dial tcp 10.0.2.15:21257: connect: connection refused
2022/02/25 11:14:25 [ERROR] dial tcp 10.0.2.15:22386: connect: connection refused
2022/02/25 11:14:29 [ERROR] dial tcp 10.0.2.15:22386: connect: connection refused
2022/02/25 12:05:31 [INFO] Running fabio as UID=0 EUID=0 GID=0
2022/02/25 12:05:31 [WARN] 

	************************************************************
	You are running fabio as root without the '-insecure' flag
	This will stop working with fabio 1.7!
	************************************************************

2022/02/25 13:05:31 [INFO] Running fabio as UID=0 EUID=0 GID=0
2022/02/25 13:05:31 [WARN] 

	************************************************************
	You are running fabio as root without the '-insecure' flag
	This will stop working with fabio 1.7!

Any help would be welcome. Let me know if I need to share more information.

Found a possible solution. I’m going to try this out.