0

I'm trying to set up a pihole server behind nginx (as a proof of concept more than that it's practically necessary to do so). I'm running both in Proxmox, pihole running as a docker image in a VM (IP 10.0.50.99, pihole web interface at port 8080) and nginx running in a container (IP 10.0.50.98). My nginx configuration is as follows (I've been messing with it a bit to try to get things working, so feel free to point out things that are redundant or wrong!):

server {
        # Listen op IPv4 and redirect to HTTPS
        listen          80;

        server_name     10.0.50.98;
        return          302 https://$server_name$request_uri;

}

server {

        # Configure SSL
        listen                  443 ssl http2;

        ssl_certificate         /etc/ssl/cert.pem;
        ssl_certificate_key     /etc/ssl/key.pem;

        server_name _;

        location / {
                try_files /index.html =404;
        }

        location /pihole {
                # Works, but how would true proxy work?
                # rewrite ^ http://10.0.50.99:8080/admin/ permanent;
                proxy_pass                              http://10.0.50.99:8080/admin/;
                proxy_set_header Host                   $host;
                proxy_set_header X-Real-IP              $remote_addr;
                proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
        }
}

If I load 10.0.50.98 in my browser, I get shown the index.html page over HTTPS, so that works as intended. However, when I go to 10.0.50.98/pihole, I get redirected to 10.0.50.98/login.php (Pihole redirects /admin to /admin/login.php), for which nginx serves me the index.html file again. If I go to 10.0.50.98/admin/login.php I see the login screen, but after logging in I'm again directed to 10.0.50.98/admin and am shown index.html again.

My question is: How do I configure things so that when I go to 10.0.50.98/pihole, it redirects me to 10.0.50.98/pihole/index.php and I can login properly?

Jonathan
  • 1
  • 1
  • Hmm it helps at least. Based on the answer there too I'll just try to set up subdomains to circumvent the problem. Thanks! – Jonathan Oct 10 '22 at 16:32

0 Answers0