Bind Lighttpd to IP

Bind Lighttpd to Specific IP

I run Nextcloud, Gogs plus a few others services on this one machine. I have a public /28 and use 1-to-1 NATs on my PA for some of my services.

System Info

uname -a
Linux srv 4.15.0-109-generic #110-Ubuntu SMP Tue Jun 23 02:39:32 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Netplan Config

/etc/netplan/01-network.yaml.
network:
    version: 2
    ethernets:
        eno1:
           addresses:
             - 192.168.20.66/28
             - 192.168.20.67/28
             - 192.168.20.68/28
             - 192.168.20.69/28
             - 192.168.20.70/28
             - 192.168.20.71/28`

Lighttpd Error

sudo journalctl -u lighttpd
Jul 08 20:20:07 srv lighttpd[13206]: 2020-07-08 20:20:07: (network.c.477) can't bind to port: 192.168.20.67 80 Address already in use

Lighttpd Config

/etc/lighttpd/external.conf
server.bind = "192.168.20.67"

Pihole Config

/etc/pihole/setupVars.conf
PIHOLE_INTERFACE=eno1
IPV4_ADDRESS=192.168.20.67/28
PIHOLE_DNS_1=9.9.9.9
PIHOLE_DNS_2=149.112.112.112
QUERY_LOGGING=true
INSTALL_WEB_SERVER=true
INSTALL_WEB_INTERFACE=true
LIGHTTPD_ENABLED=true
WEBPASSWORD=****
BLOCKING_ENABLED=true

IPv6 Disabled

cat /proc/sys/net/ipv6/conf/all/disable_ipv6
1

Ports

sudo netstat -nltup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:4711          0.0.0.0:*               LISTEN      1521/pihole-FTL
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      1494/mysqld
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      1126/redis-server 1
tcp        0      0 192.168.20.71:8080      0.0.0.0:*               LISTEN      2342/nitter
tcp        0      0 0.0.0.0:49              0.0.0.0:*               LISTEN      2236/tac_plus
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      1521/pihole-FTL
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2230/sshd
tcp        0      0 192.168.20.68:3000      0.0.0.0:*               LISTEN      26687/gogs
tcp        0      0 0.0.0.0:19999           0.0.0.0:*               LISTEN      1740/netdata
tcp6       0      0 :::80                   :::*                    LISTEN      1367/apache2
tcp6       0      0 :::49                   :::*                    LISTEN      2236/tac_plus
tcp6       0      0 :::53                   :::*                    LISTEN      1521/pihole-FTL
tcp6       0      0 :::22                   :::*                    LISTEN      2230/sshd
tcp6       0      0 :::443                  :::*                    LISTEN      1367/apache2
tcp6       0      0 :::19999                :::*                    LISTEN      1740/netdata
udp        0      0 0.0.0.0:53              0.0.0.0:*                           1521/pihole-FTL
udp        0      0 0.0.0.0:68              0.0.0.0:*                           1314/dhcpcd
udp        0      0 0.0.0.0:161             0.0.0.0:*                           1145/snmpd
udp        0      0 0.0.0.0:47425           0.0.0.0:*                           1145/snmpd
udp6       0      0 :::53                   :::*                                1521/pihole-FTL

Not sure why netstat shows tcp6 lines when it's disabled...

Nextcloud Apache2 Config (shortened)

/etc/apache2/sites-available/nextcloud.conf
<VirtualHost 192.168.20.69:80>
...
<VirtualHost 192.168.20.69:443>
...

So there's all the important info. Pihole DNS is working, but the web page is not. What am I missing?

1 Like

Apache2 is on port 80, and this is preventing lighttpd from binding to that port. Apache2 is not a supported web server. You have several options:

  1. Move either lightttpd or Apache2 to a different port. This will let them run simultaneously.
  2. Search this forum for Apache2 for user configurations to make it work as the Pi-hole web server.

https://discourse.pi-hole.net/search?expanded=true&q=apache%20%23bugs-problems-issues%3Acommunity-help

So despite the Apache2 VirtualHost being set to the IP, which is working, Apache2 binds to, I'm guessing, the loopback on 80, therefore preventing anything else for listening on it?

What about Nginx? I don't think it would be too much trouble to move Nextcloud to that.

nginx is another unsupported server, but there are user guides for this as well.

https://docs.pi-hole.net/guides/nginx-configuration/

Lighttpd can be changed to an alternate port by editing /etc/lighttpd/lighttpd.conf and changing server.port to something other than 80. Note this is subject to overwrite on a Pi-hole update or repair.

So, I got it working.

/etc/apache2/ports.conf
Listen 192.168.20.69:80

Not sure what the purpose of this file is in Apache2, but changing the default Listen 80 to the above allowed Lighttpd to start. Web page is now accessible.

What did you mean when you said Apache2 or Nginx aren't supported? As in, Pihole can't use them?

The Pi-hole team does not provide support for these, as lighttpd is the officially supported webserver. Pi-hole can use these, but support for this comes from other users.