Score:0

Pihole behing Nginx doesn't work

bd flag

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 avatar
bd flag
Hmm it helps at least. Based on the answer there too I'll just try to set up subdomains to circumvent the problem. Thanks!
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.