Jul 31, 2024 3 min read

AdGuard Home: The Ultimate Guide to Self-Hosting

AdGuard Home: The Ultimate Guide to Self-Hosting
Table of Contents

AdGuard Home is a powerful self-hosted network-wide ad blocker and tracker blocker. It works as a DNS server to filter unwanted content at the DNS level, giving you full control over your browsing experience. By hosting AdGuard Home yourself, you can enhance privacy, reduce dependency on third-party services, and customize it to meet your needs. In this guide, we'll cover installation, configuration, logging, backups, updates, and leveraging AdGuard Home's unique features.

Installing AdGuard Home

πŸ“¦ Docker/Docker Compose Setup

Using Docker is one of the most efficient ways to deploy AdGuard Home. Here's how to set it up with Docker Compose:

  1. Create a docker-compose.yml file tailored to AdGuard Home:

version: "3.8"

services:

adguardhome:

image: adguard/adguardhome:latest

container_name: adguardhome

restart: unless-stopped

ports:

- "53:53/tcp"

- "53:53/udp"

- "67:67/udp"

- "80:80/tcp"

- "443:443/tcp"

- "3000:3000/tcp"

volumes:

- ./adguard/work:/opt/adguardhome/work

- ./adguard/conf:/opt/adguardhome/conf

environment:

- TZ=UTC

  1. Bring up the container using Docker Compose:

docker-compose up -d

This will set up AdGuard Home to persist configurations and logs in the ./adguard directory.

πŸš€ Manual Installation

For those deploying directly on a Linux server, follow these steps:

  1. Download the latest version of AdGuard Home:

curl -sSL https://static.adguard.com/adguardhome/release/AdGuardHome_linux_amd64.tar.gz -o AdGuardHome.tar.gz

  1. Extract the downloaded file:

tar -xvf AdGuardHome.tar.gz

cd AdGuardHome

  1. Run the installation script:

sudo ./AdGuardHome -s install

This will install and automatically start AdGuard Home as a system service.


Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

To route traffic to AdGuard Home, configure Nginx to act as a reverse proxy:

  1. Create a new Nginx server block configuration file (e.g., /etc/nginx/sites-available/adguard):

server {

listen 80;

server_name adguard.example.com;

location / {

proxy_pass http://127.0.0.1:3000;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

}

  1. Enable the site and reload Nginx:

sudo ln -s /etc/nginx/sites-available/adguard /etc/nginx/sites-enabled/

sudo nginx -t

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Secure AdGuard Home with a Let's Encrypt SSL certificate:

  1. Install Certbot:

sudo apt install certbot python3-certbot-nginx

  1. Obtain and configure the certificate:

sudo certbot --nginx -d adguard.example.com

  1. Automate SSL certificate renewal:

sudo systemctl enable certbot.timer


Logging and Debugging AdGuard Home

πŸ—ƒοΈ Enabling Debug Logs

To enable debug logging in AdGuard Home, edit the AdGuardHome.yaml configuration file:


log_level: debug

Restart the service to apply changes:


sudo systemctl restart AdGuardHome

πŸ“„ Viewing Logs

For Docker users:


docker logs -f adguardhome

For manual installations, logs are stored in the work directory:


tail -f /opt/AdGuardHome/work/logs.txt

πŸ› οΈ Troubleshooting Common Issues

  • Check system-level logs for DNS or binding errors:

sudo journalctl -u AdGuardHome

  • Verify if other applications are using conflicting ports with:

sudo netstat -tulnp


Backup and Restore

πŸ—‚οΈ File-Based Backups

Back up the configuration and work directories:


sudo tar -czvf adguard-backup-$(date +%F).tar.gz /opt/AdGuardHome/conf /opt/AdGuardHome/work

πŸ“… Automated Backup Scripts

Create a cron job to back up AdGuard Home daily:


crontab -e

Add the following line to schedule backups at 2 AM daily:


0 2 * * * tar -czvf /var/backups/adguard-backup-$(date +\%F).tar.gz /opt/AdGuardHome/conf /opt/AdGuardHome/work


Updating and Upgrading AdGuard Home

⬆️ Updating Docker Images

To update AdGuard Home when using Docker:


docker-compose pull

docker-compose up -d

πŸ› οΈ Manual Updates

For manual installations, download the latest version and overwrite the existing files:


curl -sSL https://static.adguard.com/adguardhome/release/AdGuardHome_linux_amd64.tar.gz -o AdGuardHome.tar.gz

tar -xvf AdGuardHome.tar.gz

sudo ./AdGuardHome -s install


Leveraging AdGuard Home’s Unique Features

πŸ”§ Enabling APIs

AdGuard Home provides an API for advanced integrations. Enable it in AdGuardHome.yaml:


api:

enabled: true

bind_addr: 0.0.0.0:3000

Restart the service:


sudo systemctl restart AdGuardHome

Test the API with a simple curl request:


curl -X GET "http://127.0.0.1:3000/control/status"


AdGuard Home empowers you to take control of your network’s privacy and performance. With this guide, you now have the tools to deploy, configure, and manage it effectively. Start leveraging its powerful features and enjoy an ad-free, secure browsing experience!

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Selfhosted Ninja.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.