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 | ![]() |
|
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:
- Configure each PI with latest raspbian image https://www.raspberrypi.org/downloads/raspbian/
- add ssh file to sd card to enable ssh on boot (see option 3) https://www.raspberrypi.org/documentation/remote-access/ssh/
- Boot pi find IP and ssh into it
- Set video ram split and expand file system to card
- On two of the pis install pihole https://pi-hole.net/
- Follow this guide for getting the displays to work (pihole): https://learn.adafruit.com/pi-hole-ad-blocker-with-pi-zero-w?view=all
- On the other pi install nginx load balancer (sudo apt install nginx)
- Follow this guide for getting the display to work (non-pihole pi) https://learn.adafruit.com/adafruit-pioled-128×32-mini-oled-for-raspberry-pi Note: you will want to modify the code on this so the oled is not always on. See code in the pihole config guide to see how to do this
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/