High availability Pi-hole cluster with Nginx load balancing

This is a quick write up for the hardware and software config for the high availability Pi-hole cluster with Nginx load balancing.

Hardware:

List of components used:

Name Part Number Quantity Link
raspbery pi single board computers (with cases and SD card) 3
USB A male to micro usb cables 3 https://amzn.to/2x9OdK6
6″ Ethernet patch cables 4 https://amzn.to/2KCi7K4
gigabit switch that has 5V input AM-SG205 1 https://amzn.to/2VGYGGy
5V 10A amp power supply Mean Well LRS-50-5 1 https://amzn.to/3aFPkic
Wire https://amzn.to/2Y2wv6q
Crimp ferrules https://amzn.to/3aH4a8c
Double Stick tape https://amzn.to/35eHUSg
panel mount Ethernet connector 1 https://amzn.to/2VGYMOq
usb to power PCB 2 Order from OSH Park
dupont female to female connector (for display) 18 https://amzn.to/3cPOkKa
PiOLED 0.91inch 3 https://amzn.to/2zyjJlV
1U rack mount case

Setup notes:

To configure the load balancer:

Add this to nginx.conf (make sure to change IPs to match your two pihole pi)

stream {
upstream dns_servers {
server 192.168.1.136:53 fail_timeout=60s;
server 192.168.1.152:53 fail_timeout=60s;
}
server {
listen 53 udp;
listen 53; #tcp
proxy_pass dns_servers;
error_log /var/log/nginx/dns.log info;
proxy_responses 1;
proxy_timeout 1s;
}
}

to restart nginix run this:

sudo /etc/init.d/nginx restart

See this page for details https://www.nginx.com/blog/load-balancing-dns-traffic-nginx-plus/

Advertisement