Lighttpd on Turris 1.X doesn't handle $HTTP["host"]?

Hi there, I am struggling with the following: I’d like to have access to Turris via 2 domains: turris.lan and dhcp.lan.

I saw that lighttpd has an option to define rules in /etc/lighttpd/lighttpd.conf with conditionals, so I changed the file in the following manner:

$HTTP[“host”] =~ “(^|.)dhcp.lan$” {
server.document-root = “/www/dhcp.lan”
server.errorlog = “/var/log/lighttpd/dhcp.lan-error.log”
accesslog.filename = “/var/log/lighttpd/dhcp.lan-access.log”
}

$HTTP[“host”] =~ “(^|.)turris.lan$” { #FDQN
server.document-root = “/www”
server.errorlog = “/var/log/lighttpd/error.log”
}

The verify process of lighttpd shows no issue, but the webserver refuses any connection on any of these two domains.

Is the lighttpd limited in features in Turris 1.x (TurrisOS 6.2.3) or do I have a mistake in my understanding?

Thank you for help!

Why document root “/www/dhcp.lan” ?
Have you tried “/www” ?

Hello iron-maiden,

that’s because the virtual host “dhcp.lan” serves different content than “reforis” or “luci”.
I wanted to have a service that lists the content of /tmp/dhcp.leases.

I found out that the issue is in the file 90-turris-root.conf, specifically alias.url += ("/" => "/www/turris-webapps/") so I moved the line into the $HTTP[“host”] =~ “turris.lan” and here we go!

The lighttpd -tt is very powerful tool to test it :slight_smile:, too!

Comment: the else in lighttpd.conf doesn’t work even if official version of lighttpd shall support it.

@edison_cz: the else in lighttpd.conf works. (Source: I am a lighttpd developer.) If your syntax is incorrect, then it might not work, but you have not shared your syntax. lighttpd -p -f /etc/lighttpd/lighttpd.conf will show you the entire lighttpd configuration (including config generated by include_shell scripts) which lighttpd sees.

Back on topic, to override the Turris-provided config which sets alias.url in the lighttpd.conf global scope, you can define your own override to clear the aliases (along with the rest of your config, omitted here):

    $HTTP[“host”] =~ “(^|.)dhcp.lan$” {
        alias.url = ()
    }
    $HTTP[“host”] =~ “(^|.)turris.lan$” { #FDQN
        alias.url = ()
    }

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