Pihole is an incredible easy to use and install AdBlocking Server with an easy to use web interface. PiHole works by replacing your current DNS server and uses multiple blocklists to block malicious DNS queries and AD Sites.
Begin setting your server on a static IP, guide here.
$ git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
$ cd Pi-hole/automated\ install/
$ ./basic-install.sh
Follow on screen instructions.
Set password for webgui.
$ sudo pihole -a -p
Allow DNS in firewall.
sudo ufw allow http
sudo ufw allow https
sudo ufw allow 53
By default this installation comes with lighttpd
, we will uninstall this and manage http and https requests with nginx instead.
$ sudo apt purge lighttpd
$ sudo apt autoremove
$ sudo apt install nginx
PiHole runs PHP, install this.
$ sudo apt-get install php-fpm
$ sudo nano /etc/php/7.2/fpm/php.ini
Set cgi.fix_pathinfo
to 0
.
cgi.fix_pathinfo=0
$ sudo systemctl restart php7.2-fpm
Set up domain and path to PiHole webgui files.
$ cp /etc/nginx/sites-available/default /etc/nginx/sites-available/yourdomain
$ nano /etc/nginx/sites-available/yourdomain
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name yourdomain.com;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Activate site.
$ sudo ln -s /etc/nginx/sites-available/yourdomain /etc/nginx/sites-enabled
$ sudo systemctl reload nginx
You should now be all set. Point your router to use this server as DNS.