Pi-hole + Nginx Proxy Manager Setup Guide on Raspberry Pi (Docker)

1. Prepare Your Pi

Update system and install Docker + Docker Compose:

sudo apt update && sudo apt upgrade -y
sudo apt install docker.io docker-compose -y
sudo systemctl enable docker
sudo usermod -aG docker $USER

Important: Log out and back in (or reboot) to apply Docker group changes:

newgrp docker

2. Create Docker Compose File

Make a folder for your self-hosted apps and open an editor:

mkdir -p ~/selfhosted && cd ~/selfhosted
nano docker-compose.yml

Paste this content into docker-compose.yml (replace 'your-secure-password' with your Pi-hole admin password):

version: '3'

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    environment:
      TZ: 'Etc/UTC'
      WEBPASSWORD: 'ilyaas2012'
    volumes:
      - './pihole/etc-pihole:/etc/pihole'
      - './pihole/etc-dnsmasq.d:/etc/dnsmasq.d'
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "8081:80/tcp"
    restart: unless-stopped
    cap_add:
      - NET_ADMIN

  nginx-proxy-manager:
    container_name: nginx-proxy-manager
    image: jc21/nginx-proxy-manager:latest
    restart: unless-stopped
    ports:
      - "81:81"   # web UI dashboard port
      - "80:80"   # HTTP port for redirects / proxying
      - "443:443" # HTTPS port
    volumes:
      - ./nginx-proxy-manager/data:/data
      - ./nginx-proxy-manager/letsencrypt:/etc/letsencrypt

3. Start the Containers

Run this command to download images and start Pi-hole and Nginx Proxy Manager:

docker compose up -d

4. Access the Web Interfaces

5. Configure Pi-hole

To use Pi-hole as your DNS server:

  1. Go to your router’s admin page.
  2. Find DNS settings.
  3. Set the primary DNS server to your Pi’s IP address.
  4. Save and reboot router if needed.

OR manually set the DNS on your devices to your Pi IP.

6. Configure Redirects in Nginx Proxy Manager

Once logged into Nginx Proxy Manager dashboard:

  1. Go to Hosts > Proxy Hosts or Redirection Hosts.
  2. Add a new redirection from discord.com (or your custom domain) to https://google.com.
  3. Save and enable the redirect.
  4. Your network devices (using Pi-hole DNS) will then resolve domain, and Nginx Proxy Manager will handle HTTP redirects.

7. Bonus: Updating

To update your containers later, run:

docker compose pull
docker compose up -d

Need Help?

If you want me to:

Just ask!

Enjoy your ad-free, redirect-capable network on Pi! 🎉