Skip to content

Instantly share code, notes, and snippets.

@kmagdziak
Last active November 5, 2021 04:36
Show Gist options
  • Save kmagdziak/49daac58bad7071e36a738da8aadb58e to your computer and use it in GitHub Desktop.
Save kmagdziak/49daac58bad7071e36a738da8aadb58e to your computer and use it in GitHub Desktop.
Running Pi-hole Docker Container with different docker port 80 mapping
Issue: Changing the docker port 80 to hosted port not 80 causes the following message:
[ERROR]: Unable to parse results from queryads.php: Unhandled error message (Invalid domain!)
## Solution courtesy of unitpas, modified by kmagdziak
docker exec -it pihole apt-get update
docker exec -it pihole apt-get install nano
docker exec -it pihole bash
nano /var/www/html/pihole/index.php
change
$serverName = htmlspecialchars($_SERVER["HTTP_HOST"]);
with
$serverName = htmlspecialchars($_SERVER["SERVER_ADDR"]);
Ctrl+O to save
Ctrl+X to exit
reload web page
@Kaifeck
Copy link

Kaifeck commented Jan 8, 2020

Works like a charm. Thanks, m8!

@MensSana
Copy link

Awesome!
Also, instead of updating aptitude cache and installing nano for this single purpose, your can do it this way:
docker exec -it pihole sed -iE 's/"HTTP_HOST"/"SERVER_ADDR"/' /var/www/html/pihole/index.php

@CodyFraker
Copy link

This worked for me as well when using https://github.com/gcgarner/IOTstack
IOT Stack

@vgenie
Copy link

vgenie commented Apr 19, 2020

It really works, thank you very much~

@argentdeux
Copy link

Due to a recent update this has now changed, the line to look for is:

$serverName = htmlspecialchars($_SERVER["SERVER_NAME"]);
and as before, change it to
$serverName = htmlspecialchars($_SERVER["SERVER_ADDR"]);

@karezza
Copy link

karezza commented Jul 3, 2021

This also worked for me, looks like it needs to make it into the master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment