Cant uses 404 response handle of lighttpd

Hi everyone, I tried to set an response for the lighttpd handle 404 but it didnt worked.
I started to configure the lighttpd.conf with the extra line server.error-handler-404 = "/var/www/html/admin/404.html" but it wonted work. So I saw the post Pi-hole FTL v5.20.1, Web v5.18.1 and Core v5.15 released. But after the shurt command nothing happens. I know about the specifiy of the pihole-FTL with BLOCKINGMODE=IP. I tried everything especially after I saw the lighttpd specification Server error-handler-404Details - Lighttpd - lighty labs. Im now really frustrated and don't know what to do. Is there any entry that I have to change to switch between the 0.0.0.0 response and the 404 response or anything else.

What specifically are you trying to accomplish? What is the URL that is producing the 404 response?

I like to have a modified response of a blocked page. One of the domains I tried was bild.de. Its in the Regex Blacklist.

If the page in question is using the https protocol (as in your case) you cannot serve a block page without inserting your own SSL certificate.

It's not a good idea to edit the lighttpd.conf directly. Pi-hole (for now) manages it.

I use a file in /etc/lighttpd/conf-available/15-lighttpd-secure-proxy.conf which contains a line: server.error-handler-404 := "/error_404.html". which overrides the default in lighttpd.conf because of the := syntax.

I then link that file into /etc/lighttpd/conf-enabled/. Note: the configuration doesn't require a full path. Things are 'rooted' at /var/www/html already.

I then have my error file: /var/www/html/error_404.html, which works great if I typo a URL, etc. I also have an index.html, which shows various useful links in my environment, since I have more hosted on lighttpd other than pi-hole.

1 Like

If decide to drop your own config file in the /etc/lighttpd/conf-available/ folder:

pi@ph5b:~ $ cat /etc/lighttpd/conf-available/README
ligghttpd Configuration under Debian GNU/Linux
==============================================

Files and Directories in /etc/lighttpd:
---------------------------------------

lighttpd.conf:
         main configuration file

conf-available/
        This directory contains a series of .conf files. These files contain
        configuration directives necessary to load and run webserver modules.
        If you want to create your own files they names should be
        build as nn-name.conf where "nn" is two digit number (number
        is used to find order for loading files)

conf-enabled/
        To actually enable a module for lighttpd, it is necessary to create a
        symlink in this directory to the .conf file in conf-available/.

Enabling and disabling modules could be done by provided
/usr/sbin/lighty-enable-mod and /usr/sbin/lighty-disable-mod scripts.
pi@ph5b:~ $ tree /etc/lighttpd/conf-*
/etc/lighttpd/conf-available
├── 05-auth.conf
├── 05-setenv.conf
├── 10-accesslog.conf
├── 10-cgi.conf
├── 10-dir-listing.conf
├── 10-evasive.conf
├── 10-evhost.conf
├── 10-expire.conf
├── 10-fastcgi.conf
├── 10-flv-streaming.conf
├── 10-no-www.conf
├── 10-proxy.conf
├── 10-rewrite.conf
├── 10-rrdtool.conf
├── 10-simple-vhost.conf
├── 10-sockproxy.conf
├── 10-ssi.conf
├── 10-status.conf
├── 10-userdir.conf
├── 10-usertrack.conf
├── 11-extforward.conf
├── 15-fastcgi-php.conf
├── 15-fastcgi-php-fpm.conf
├── 90-debian-doc.conf
├── 99-unconfigured.conf
└── README
/etc/lighttpd/conf-enabled
├── 10-fastcgi.conf -> ../conf-available/10-fastcgi.conf
├── 15-fastcgi-php.conf -> ../conf-available/15-fastcgi-php.conf
└── 99-unconfigured.conf -> ../conf-available/99-unconfigured.conf
pi@ph5b:~ $ sudo lighty-enable-mod
Disabled modules: accesslog auth cgi debian-doc dir-listing evasive evhost expire extforward fastcgi-php-fpm flv-streaming no-www proxy rewrite rrdtool setenv simple-vhost sockproxy ssi status userdir usertrack
Enabled modules: fastcgi fastcgi-php unconfigured
Enable module:

And:

option : NAME = VALUE
merge : NAME += VALUE
replace : NAME := VALUE (replace/overwrite earlier value) (since 1.4.46)

EDIT: Ow sorry, above older PH release doesnt have its own PH module yet.
Below is a current release and it does have that PH symlink:

pi@ph5a:~ $ readlink /etc/lighttpd/conf-enabled/15-pihole-admin.conf
../conf-available/15-pihole-admin.conf

Thanks for the replies. It really helps to understand the system and how to handle with it. I thought that it is possible to show on any website (http|https) a modified error page but it only works with http.

1 Like

It will all be moot when v6 arrives which comes with its own embedded web daemon.

1 Like

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