Using PiHole lighttpd webserver as a light local host

Raspberry Pi2b
RaspiOS lite (bullseye)
lighttpd

I was having issues with an old PiHole install (4+ yrs) on a Rpi2b where it had been blocking some valid addresses even when adding to the whitelist or when disabled. My docker PiHole had no issues but the Pi was getting gradually worse, so I set some time aside to rebuild the RPi2b.

Now it's back up with all my lists in and just a few final admin tasks to go.
One of the tasks was to reuse the lighttpd server for some simple pages as I had in my old pihole.

The pages are static like a bookmark page, and used as a homepage for my browsers.
Useful to have as a simple homepage + it's an early warning if the RPi is offline.

With the new install of PiHole, it doesn't seem to like having the files to be added to serve up.
It looks like it's doing some stricter filtering in how it shares content.

Every search I've done refers to editing older configs. The content of which is no longer present in the new version's lighttpd.conf file

I could install docker nginx to serve them up, but that seems overkill when there's already a webserver running.

So the question I have is:

Is there a way to configure pihole to allow it to serve up personal pages?
e.g. http://[piholeip]/mylinks/index.php

Pi-hole doesn't serve the pages. You need to configure lighttpd to serve the pages. You don't need to change pi-hole config files.

If you did a clean install, the new lighttpd config shipped with pi-hole is a little different from the older config.

Now, the new /etc/lighttpd/lighttpd.conf can be edited if you want, but usually you just need to add extra config to the directory: /etc/lighttpd/conf-enabled/.

If your old configuration was using external.conf you will need to adapt it.

The old file /etc/lighttpd/external.conf is not used anymore, but you can move the file to /etc/lighttpd/conf-enabled/20-my-personal-pages.conf (actually you can use any filename you want in this directory).

Thanks, I'll give it a go :+1:

This is an untested config file, created using Pi-hole config as a template:

$HTTP["url"] =~ "^/mylinks/" {
    server.document-root = "/var/www/html"
    server.stream-response-body = 1
    accesslog.filename = "/var/log/lighttpd/access-mylinks.log"
    accesslog.format = "%{%s}t|%h|%V|%r|%s|%b"

    fastcgi.server = (
        ".php" => (
            "localhost" => (
                "socket" => "/run/lighttpd/mylinks-php-fastcgi.socket",
                "bin-path" => "/usr/bin/php-cgi",
                "min-procs" => 1,
                "max-procs" => 4,
                "bin-environment" => (
                    "TZ" => "America/Sao_Paulo",
                    "PHP_FCGI_CHILDREN" => "4",
                    "PHP_FCGI_MAX_REQUESTS" => "10000",
                ),
                "bin-copy-environment" => (
                    "PATH", "SHELL", "USER"
                ),
                "broken-scriptfilename" => "enable",
            )
        )
    )

    # Block . files from being served, such as .git, .github, .gitignore
    $HTTP["url"] =~ "^/mylinks/\." {
        url.access-deny = ("")
    }

}
else $HTTP["url"] == "/mylinks" {
    url.redirect = ("" => "/mylinks/")
}

You probably only need the fastcgi.server part to run PHP files.

Thanks for this. I'd been trying lots of iterations including older apache config and the server either didn't start or did, but no personal pages showing (404)

I also tried the 10-userdir.config, but no luck with that either.

For the lighttpd config I created a custom file: /etc/lighttpd/conf-available/91-personal-pages.conf
Then a symbolic link in /etc/lighttpd/conf-enable

cd /etc/lighttpd/conf-enabled
ln -s ../conf-available/91-personal-pages.conf ./

I tried your sample, but unfortunately I got an error when restarting the daemon

/etc/init.d/lighttpd restart
Restarting lighttpd (via systemctl): lighttpd.serviceJob for lighttpd.service failed because the control process exited with error code.
See "systemctl status lighttpd.service" and "journalctl -xe" for details.
 failed!

Checking the config it fails as it's loading the configuration files

lighttpd -tt -f /etc/lighttpd/lighttpd.conf
2023-10-25 21:31:29: configfile.c.1984) opening configfile /etc/lighttpd/conf-enabled/91-personal-pages.conf failed: Too many levels of symbolic links
2023-10-25 21:31:29: configfile.c.1970) source: /etc/lighttpd/lighttpd.conf line: 51 pos: 15 parser failed somehow near here: (EOL)

But I did notice that if I remove the .php from "static-file.exclude-extensions" then the browser downloads the index file.

#static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
static-file.exclude-extensions = ( ".pl", ".fcgi" )

Just need to get it to display in the browser rather than download the file and it should be ok.
*.html works fine. Just *.php that isn't showing in browser
Trying to figure that out atm...

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