I've installed PiHole on 2 Raspberry Pis. On one, all went well, although I had some issues starting FTL, on the 2nd one I seem not to be able to login, everytime I try I get redirected to the Dashboard with no login done. Even if I login with CTRL+Enter I see the setting page, but everytime I select another page on the left menu or save the settings I get redirected to the login page again.
Found the issue, I just don't know how to solve it.
On this Pi I have a NextCloud server, and so I have this configuration on apache /etc/apache2/sites-available/000-default.conf with a dynamic DNS server to access it from the internet:
RewriteEngine on
RewriteCond %{SERVER_NAME} =MYSERVERNAME.ddns.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure
#Header set Set-Cookie HttpOnly;Secure
</VirtualHost>
So if I open the site using the external address all is fine. But I don't what to have PiHole accessible from the Internet. Any ideas how to fix it?
Just as a tip: You can use what Pi-hole installed and just change the port. You will have to re-do this after an update as an update runs pihole -r which is "fixing" the port away (in case a user misconfigured it). There is an open Feature Request for memorizing the port, you may want to vote for this.
It may not be enough, I believe I also need to change the path used to serve the webpage (/var/www/html/), and move the Pi-hole files overthere, otherwise it will still be available in Apache.
Solution was much simpler. I just followed this answer to add the location directive to the apache configuration files for the admin and pihole folders.
In the end they look like this:
<Directory /var/www/html/admin>
Require host localhost
Require ip 127.0.0.1
Require ip 192.168
Require ip 10
</Directory>
<Directory /var/www/html/pihole>
Require host localhost
Require ip 127.0.0.1
Require ip 192.168
Require ip 10
</Directory>