I am trying to setup a Pihole as my DHCP server behind an Nginx reverse proxy, both in Docker containers. So far, I've gotten Nginx reverse proxy manager up and running, and I can remotely connect to the GUI from my devices. The eventual goal is to get it running with SSL certs so I can tunnel in from outside, but for the time being I'm just trying to get things set up locally.
I'm still very new to networks and even this has pushed me beyond what I understand.
Doing my best to follow this thread, I ended up with this docker compose file for pihole.
services:
pihole:
container_name: pihole-relay
image: pihole/pihole:latest
ports:
- "53:53/tcp"
- "53:53/udp"
restart: unless-stopped
cap_add:
- NET_ADMIN
dns:
- 127.0.0.1
- 1.1.1.1
environment:
ServerIP: xxx.xxx.x.x # This is the RPi device's static IP
DNS1: 1.1.1.1
DNS2: 1.0.0.1
VIRTUAL_HOST: pi.hole
DNSMASQ_LISTENING: all
volumes:
- '/home/pihole/pihole/:/etc/pihole/'
- '/home/pihole/dnsmasq.d/:/etc/dnsmasq.d/'
depends_on:
- dhcphelper
networks:
backend:
ipv4_address: '172.31.0.100'
nginx_default: {}
dhcphelper:
container_name: dhcp-relay
build: ./dhcp-helper-1.2
restart: unless-stopped
network_mode: "host"
command: -s 172.31.0.100
cap_add:
- NET_ADMIN
networks:
backend:
ipam:
config:
- subnet: 172.31.0.0/16
nginx_default:
external: true
I then modified pihole.toml:
etc_dnsmasq_d = true ### CHANGED, default = false
This brings the containers up and I'm not seeing any errors, but for the life of me I cannot figure out how to access the Pihole GUI, hook it up to Nginx, or get it actually work as the DHCP. I cannot access it directly via the 172.31.0.100 IP address, as that's internal to Docker's Pihole-backend network. There's another 172.22.0.1 IP internal to the nginx-proxy internal network that's listed in the inspect output as belonging to the pihole container. I get a ping response from both IPs from the RPi, but not when I ping from other devices.
I tried adding Pihole as a proxy host (see config file below), but I cannot access the domain I assigned it.
# ------------------------------------------------------------
# nginx.pihole.slice
# ------------------------------------------------------------
map $scheme $hsts_header {
https "max-age=63072000; preload";
}
server {
set $forward_scheme http;
set $server "172.22.0.3";
set $port 80;
listen 80;
#listen [::]:80;
server_name nginx.pihole.slice;
http2 off;
access_log /data/logs/proxy-host-2_access.log proxy;
error_log /data/logs/proxy-host-2_error.log warn;
location / {
# Proxy!
include conf.d/include/proxy.conf;
}
# Custom
include /data/nginx/custom/server_proxy[.]conf;
}
I'm fairly certain I'm ignorant of something obvious about how this entire system is supposed to work. My instinct is that I need to get Pihole's DNS working, but that seems redundant with the reverse proxy. I wanted to setting it as the DHCP server, but I'm not sure how to enable that from the CLI.