Hi folks,

Just set up Nginx Proxy Manager + Pihole and a new domain with Porkbun. All is working and I have all my services service.mydomain.com, however some services such as pihole seem to be strictly reachable with /admin at the end. This means with my current setup it only directs me to pihole.mydomain.com which leads to a 403 Forbidden.

This is what I have tried, but with no prevail. Not really getting the hang of this so would really appriciate a pinpoint on this :)

  • Saiwal@hub.utsukta.org
    link
    fedilink
    arrow-up
    7
    arrow-down
    1
    ·
    2 months ago

    Add the following in Advanced tab

    location / {   return 301 /admin;}location /admin {   proxy_pass [url=http://<Pi-hole-IP>:<Pi-hole-Port>/admin;]http://<Pi-hole-IP>:<Pi-hole-Port>/admin;[/url]   proxy_set_header Host $host;   proxy_set_header X-Real-IP $remote_addr;   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;   proxy_set_header X-Forwarded-Proto $scheme;}
    

    replace the IP and port

    • Sunny' 🌻@slrpnk.netOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 months ago

      Thank you for providing this, however when i now browse to pihole.mydomain.com it gives me a 404, and the URL is directed to pihole.mydomain.com/admin:8118. E.g. the port is somehow ending up at the end of the url haha.

        • Sunny' 🌻@slrpnk.netOP
          link
          fedilink
          English
          arrow-up
          3
          ·
          2 months ago

          Ahhh i got it working now! Thanks a bunch for the help, been trying to get this to work for hours now hehe

          • TedZanzibar@feddit.uk
            link
            fedilink
            English
            arrow-up
            1
            ·
            2 months ago

            Just tried this myself and mine does the same thing but I don’t have anything set in the custom locations tab. What did you do to resolve it?

            • Sunny' 🌻@slrpnk.netOP
              link
              fedilink
              English
              arrow-up
              2
              ·
              2 months ago

              Remove any custom locations (if u have tried to add any), and then simply copy paste this into the advanced tab. Dont forget to change the <IP+PORT>

              location / {
                  return 301 /admin;
              }
              location /admin {
                  proxy_pass http://<YOUR IP:PORT>/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;
                  proxy_set_header X-Forwarded-Proto $scheme;
              }
              

              Let me know how it goes :)

              • TedZanzibar@feddit.uk
                link
                fedilink
                English
                arrow-up
                2
                ·
                2 months ago

                Yeah that’s exactly what I’d done but it was insisting on trying to redirect me to the site on port 4443 for some reason.

                Fixed it in the end by reverting the NPM config to default (no advanced settings) and instead using Pihole’s VIRTUAL_HOST=pihole.mydomain.internal environment variable in the Docker compose file.

                Cheers for your help anyway!

          • K3CAN@lemmy.radio
            link
            fedilink
            English
            arrow-up
            1
            ·
            2 months ago

            If you’re going to be playing with custom locations and such, it might be worth using nginx directly instead of through the limitations of NPM.

  • sjh@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 months ago

    Hey there!

    Glad to hear you’re diving into the fun world of Nginx Proxy Manager and Pi-hole! It’s super cool once you get past the initial hurdles. So, for your issue, let’s try and simplify things a bit.

    First, you’ll want to create a new proxy host for pihole.mydomain.com and then set up a redirect rule. Here’s a quick rundown on how you can do that:

    1. Create a new proxy host:

      • Go to the ‘Hosts’ tab.
      • Click ‘Proxy Hosts’ then ‘Add Proxy Host.’
      • Enter pihole.mydomain.com in the domain name field.
    2. Set up a redirection:

      • Under the ‘Advanced’ tab, add this in Custom Nginx Configuration:
        location / {
            return 301 /admin;
        }
        
    3. Watch the magic happen!

      • Click save and your configuration should now redirect pihole.mydomain.com to pihole.mydomain.com/admin.

    If this doesn’t work right away, you might need to clear your browser’s cache or double-check that your DNS settings are pointing to the right place. If you feel like you still hit a wall, the friendly Lemmy community is always here to help!

    You’ve got this—happy troubleshooting!