Lighttpd refuses to let go of port 80 on ipv6 unless I edit lighttpd.conf

This is the problem:

user@host: ~$ sudo netstat -tulpn | grep lighttpd
tcp        0      0 0.0.0.0:1080            0.0.0.0:*               LISTEN      1653/lighttpd       
tcp6       0      0 :::80                   :::*                    LISTEN      1653/lighttpd       
tcp6       0      0 :::1080                 :::*                    LISTEN      1653/lighttpd    

I'm using caddy to handle https and it works on other installs (older, debian 11) but on this fresh install, it fights me.

I first used the "old school" external.conf and it did not work

# /etc/lighttpd/external.conf
server.port := 1080

I've added external overrides like this:

# /etc/lighttpd/conf-enabled/20-custom-port.conf
server.port := 1080
$SERVER["socket"] == "[::]:1080" {  }

and that gets me the first part of this post:

user@host: ~$ sudo netstat -tulpn | grep lighttpd
tcp        0      0 0.0.0.0:1080            0.0.0.0:*               LISTEN      1653/lighttpd       
tcp6       0      0 :::80                   :::*                    LISTEN      1653/lighttpd       
tcp6       0      0 :::1080                 :::*                    LISTEN      1653/lighttpd    

ONLY when I directly edit lighttpd.conf will it use only the port I specify instead of tacking on 80 to either ipv4 or ipv6.

# /etc/lighttpd/lighttpd.conf
...
server.port                 = 1080
...

then:

user@host: ~$ sudo netstat -tulpn | grep lighttpd
tcp        0      0 0.0.0.0:1080            0.0.0.0:*               LISTEN      1811/lighttpd       
tcp6       0      0 :::1080                 :::*                    LISTEN      1811/lighttpd  

Is there an external custom port config that disables using port 80 that I am missing? I'm worried (not WORRIED worried) that this will be overwritten with updates.

Thanks!

I think I figured something out but am not sure how to fix it.

the := operator overrides the default for ipv4 but what's the right way to handle ipv6 overrides (isntead of adding)?

You only need to use /etc/lighttpd/external.conf if you are using an old Pi-hole version (prior to v5.15) and you always kept updating this old version. That was the way Pi-hole used to configure lighttpd.

If you are on a fresh install (or your first installation was newer than v5.15, than you have the new config files. The current lighttpd config uses the original config file (developed by lighttpd - not the one Pi-hole modified) and also uses the /etc/lighttpd/conf-enabled directory.

Apparently you are using the current version.
This means:

  • /etc/lighttpd/external.conf is not used in this configuration;
  • you can add extra config files in /etc/lighttpd/conf-enabled directory;
  • you can change the port directly in /etc/lighttpd/lighttpd.conf or you can override the original port using another file (it's your choice).

Note about operators:
If you are setting the port in /etc/lighttpd/lighttpd.conf, you should use =
If you have a port already set and you want to override the port in another file, you should use :=


About IPv6:
The IPv6 port is set in /etc/lighttpd/lighttpd.conf
(it uses the server.port value set on that file):

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include "/etc/lighttpd/conf-enabled/*.conf"

Every other config files are include only after that.

If you are overriding the port in another file, this won't change the IPv6 port.

Suggestions:

  1. change the port directly in /etc/lighttpd/lighttpd.conf (this change will survive Pi-hole updates in newer versions) and remove the new file overriding the port.
    Personally, I think this is the cleaner solution.

  2. use your include file, but change the order of those lines to:

    include "/etc/lighttpd/conf-enabled/*.conf"
    # default listening port for IPv6 falls back to the IPv4 port
    include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
    

About IPv6:
The IPv6 port is set in /etc/lighttpd/lighttpd.conf
(it uses the server.port value set on that file):

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include "/etc/lighttpd/conf-enabled/*.conf"

Every other config files are include only after that.

If you are overriding the port in another file, this won't change the IPv6 port.

OK this part explains my issue.
I'll just change it in the lighttpd.conf and hope I remember if/when it breaks

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