WaLLy3K / Pi-hole-Block-Page

A "Website Blocked" page to go with https://pi-hole.net
MIT License
120 stars 12 forks source link

wrong Admin Console URL when using two Pi-Holes #22

Open Th3M3 opened 7 years ago

Th3M3 commented 7 years ago

I am using two Raspberrys in my network with pi-hole installation. No. 1 is for normal use and my DHCP-Server point to it No. 2 for testing and development.

Now I get the following issue: If I open my browser and type in the IP-Adress of Pi No. 2, then I get his "Website Blocked"-Page - as expected.

But if I click to the Admin Console Link (Did you mean to go to Pi-hole Admin Console?), I land on Raspberry No. 1, because it is the client's DNS Server and pi.hole resolves to his IP-Adress.

So what about changing the Admin Console URL to /admin instead of the absolute url pi.hole?

WaLLy3K commented 7 years ago

Hey @Th3M3, thanks for the heads up on this issue!

Changing the address to /admin alone won't work, as it'll attempt to head to http://blockedsite.com/admin (and the Admin Console likely won't work correctly due to CORS related issues). One option could be to use an IP address instead, but at this point in time, it's not the best solution.

As it stands though, this issue would be a very low priority for me (as I'm focusing most of my time directly on the Pi-hole codebase), and as a workaround, I might suggest that you set up a cron job to sync your Blacklist/Whitelist/Wildcards to your second Pi-hole daily?

You could use this code as a reference for how to do that! :smile:

Th3M3 commented 7 years ago

Changing the address to /admin alone won't work, as it'll attempt to head to http://blockedsite.com/admin (and the Admin Console likely won't work correctly due to CORS related issues). One option could be to use an IP address instead, but at this point in time, it's not the best solution.

As I understand it correctly, the This site is not blocked, but landPage is not configured. Did you mean to go to Pi-hole Admin Console?-Box only is shown when I try to go to the pi with IP-Adress, but not if a website being blocked.

Actually, I don't want to sync the Block/Whitelists.

For testing, I changed the url in index.php in line 230 to /admin and for me it works as expected.

WaLLy3K commented 7 years ago

For testing, I changed the url in index.php in line 230 to /admin and for me it works as expected.

It will load, but are you able to whitelist, or blacklist anything? My knowledge of the workings of Admin Console aren't exactly current, but my understanding is that most functions that allow changes via the Admin Console will not work.

Th3M3 commented 7 years ago

but are you able to whitelist, or blacklist anything?

I've tried it out and I can whitelist and blacklist domains, and changing Upstream DNS Server. So far it all works. I haven't had any problems yet.

For sure, because I do this on Pi No. 2(which is for development and not the client's standard DNS-Server), the changes will only used for the clients witch explicit use this Pi as DNS. Is it that what you meant?

What I want to avoid is that a link on one Pi directs me to the other. That shouldn't be and otherwise it confuses me and it could happen that I accidentally do the setting on the wrong Pi. So I think all links should be relative, as they are in the Admin Console's Navbar, to ensure to always work on the same Pi.

Th3M3 commented 7 years ago

but my understanding is that most functions that allow changes via the Admin Console will not work.

I think I now understand what you mean.

I have added chip.de to my Blacklist. After flushing the dns cache, I tried to go to that site and then I only see the Website Blocked-Site with Info "Manually Blacklisted by Wildcard". But after removing chip.de from Blacklist and refreshing the chip.de-site, the Website Blocked site asks me to go to Pi-hole Admin Console.

But shouldn't there come up another message and tell me to flush my dns cache?

When I follow the link and open up chip.de/admin to reach the Admin Console, then changes in Blacklist and Whitelist failed - as you expect it.

WaLLy3K commented 7 years ago

I've made changes that'll replace links to pi.hole with the IP address instead. The update should be out in time for Pi-hole 3.2.