Setup lighttpd reverse proxy for v6

Please follow the below template, it will help us to help you!

If you are Experiencing issues with a Pi-hole install that has non-standard elements (e.g you are using nginx instead of lighttpd, or there is some other aspect of your install that is customised) - please use the Community Help category.

Expected Behaviour:

Raspberry pi 4 4gb
64 bit Raspberry pi os lite (bookworm)
Original v5 install, upgraded with pihole up to V6
Running lighttpd as my web server managing SSL
Pihole on port 8080, local IP 192.168.1.2

How do I setup reverse proxy from mydomain.com using /pihole to access the web UI whilst retaining access to my homepage at mydomain.com?

Every config option I try either the login page hangs, or if I get to the webui, the data elements fail to load. Errors in the console complain about /api/ end point, but I can't get the proxy settings right to work with it.

Actual Behaviour:

Doesn't work

Debug Token:

https://tricorder.pi-hole.net/kDmD34qb/

@TheME

If I remember correctly you said you are using lighttpd as reverse proxy.

Can you please explain how you did it, or suggest a tutorial?

Not sure what you mean sorry? You mean you have no idea how to use lighttpd web server as a reverse proxy? I just used google to figure it out.
My config for pihole v5 is

$HTTP["url"] =~ "^/pihole2/" {
proxy.header = ("map-urlpath" => ( "/pihole2/" => "/admin/" ))
proxy.server = ( "" => ( ( "host" =>  "192.168.1.4", "port" => 80 ) ) )
}

After spending hours chatting to github ai, I have solved it. For anybody else, here is my config. The parts I think are important anyway;

Place this at the start of all your services under the same domain

$HTTP["host"] =~ "mydomain.com" {

and then for the pihole reverse proxy

    url.rewrite-once = (
        "^/pihole/admin(/.*)?$" => "/admin$1",
        "^/pihole/api(/.*)?$" => "/api$1"
    )

    # Reverse proxy for Pi-hole admin interface
    proxy.server = (
        "/admin" => (
            (
                "host" => "192.168.1.2",
                "port" => 8080
            )
        ),
        "/api" => (
            (
                "host" => "192.168.1.2",
                "port" => 8080
            )
        )
    )

    # Add X-Forwarded-Prefix header for Pi-hole
    $HTTP["url"] =~ "^/pihole" {
        setenv.add-request-header = (
            "X-Forwarded-Prefix" => "/pihole"
        )
    }
}
2 Likes

Good to hear that you figured it out alredy, as my config is different because I have set up lighttpd to expose each service to another subdomain.

Did you also need to configure the webserver.paths.prefix setting?

No, I haven't had to touch webserver.paths.prefix yet. Although I only have 1 server with pihole upgraded to V6 so far. My second server with pihole is still v5. That's on 192.168.1.4. Will need some time spare to work through whether this current proxy config will be sufficient to manage both servers.

It's that option in the webui? Or just in the pihole toml file?

It is a bit hidden in the WebUI.

You find it by

  1. Go to a settings page site and toggle the switch on the top right from Basic to Expert.
  2. You'll now find All settings in the left menu pane.
  3. On the All settings page, switch over to the Webserver and API tab to find the webserver.paths.prefix option.

But you can also change this setting from the CLI with

sudo pihole-FTL --config webserver.paths.prefix "<value>"

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.