Pi-hole interfering with website (port 80?)

Had my LAMP server up and running nicely and was able to see the default Debian/Apache page on my domain. But since setting up Pi-hole to block Ads on my network, I just receive a page that say’s ‘Blocked by Pi-hole’.

There’s a FAQ on Pi-hole Userspace that seems to be about the problem.

Since Pi-hole uses port 80 by default, it > can conflict with some existing Websites> . It’s a known issue that we are working on.

Is there a way around this? I couldn’t really make much sense of the possible solutions on there, try running it through a different port, or changing from the default page?

Not really sure what I’m talking about , but I do feel this is a problem that’s not just specific to me.

Thanks,

Tin

Hi Tin,

When PiHole blocks a advert, it redirects the request on port 80, to the IP address of the device. Because that device is running a webserver, you end up seeing the default webpage (/var/www/index.html). This page contains the text “blocked by PiHole”.

If we look at /etc/pihole/gravity.list, we can see how it works:

192.168.0.111 001wen.com

The above shows that any requests made to 001wen.com will be redirected to 192.168.0.111.

Theres a few options to free up the webserver’s default page:
Option 1:
Change all IP address entries in /etc/pihole/gravity.list to a null IP address, eg: 0.0.0.0 . The advert will still be blocked, but it wont be redirected to the webpage on the device. This then free’s up /var/www/index.html.

#Redirect blocked sites to a null IP address
sed -i "s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/0.0.0.0/" /etc/pihole/gravity.list


Option 2:
Overwrite /var/www/index.html with something else. Bear in mind, this page will also be displayed on the client device, everytime PiHole blocks an advert.

Option 3:
Move your website to a subdirectory, eg: /var/www/mywebsite/index.html, then you can access the site with http://myserver/mywebsite

Hi Fourdee, thanks for your extensive reply! I have a lot better idea of what’s going on now, one of these options will definitely work for me I’m sure.

Tin

got the same issue even if i uninstall pihole, any suggestions? im using lighttpd

The webpage will still exist after uninstall. If the default page is showing “Blocked by PiHole”, you can remove it with:

rm /var/www/index.html

You will then need to replace the file above with something else as your default website page. Or you can redirect it to another folder (eg /var/www/owncloud).
If you need assistance with setting this up, or, still having issues, just let me know.

Im having issues to redirect to nextcloud folder,I realized im a newbie >_> thx in advance

ps i switched to apache2 and now i cant change back to lighttpd :rofl:

We can change the default directory Apache2 uses, see below:

You’ll need to edit the following file:

nano /etc/apache2/sites-available/000-default.conf

Find that line that says DocumentRoot /var/www and change to:

DocumentRoot /var/www/nextcloud

To save changes, press:
CTRL+X, press Y, then press enter.

Restart the services with:

dietpi-services restart

When you goto your http://ipaddress, Next cloud should be the default page.

done, but now I see the apache2 debian default page , this has no sense, it should works

Yep, can you paste contents of:

cat /etc/apache2/sites-available/000-default.conf

And make sure you restarted services:

dietpi-services restart
ErrorLog /error.log
        #CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =myserver.duckdns.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>

Strange, DocumentRoot /var/www/nextcloud is missing. Is this the full contents of the file?

yep it is, I’ve never touched anything about this folder, nevermind, I’m going to make a fresh install of the whole system soon :smiley: