I got my Pi-Hole set up and working as intended. I'm now trying to run a second webserver (nginx) on the same pi to run some websites. I set up two ip's on eth0 with netplan:
network:
ethernets:
eth0:
addresses:
- 172.16.1.2/24
- 172.16.1.3/24
dhcp4: no
gateway4: 172.16.1.1
nameservers:
addresses: [127.0.0.1]
optional: true
version: 2
This works fine, I can ping both addresses and get an answer. I edited /etc/lighttpd/external.conf
to have following inside: server.bind = "172.16.1.2"
It's got only this inside. Nginx I set to listen only on the other ip (172.16.1.3) and on Port 80
Also I changed the root-directory of Nginx to /var/www/nginx
instead of the standard /var/www/html
to have it better separated
Expected Behaviour:
Pi-hole web-GUI is available under http://IP:80/admin
My own hosted websites (right now the default nginx "It works" page, adding mine when it works) are available at http://SecondIP:80/whatever
Actual Behaviour:
Pi-hole GUI is accessible with http://IP:80/admin
Own hosted website (nginx-page) gets ERR_CONNECTION REFUSED on http://SecondIP:80/whatever
When I set Nginx to listen on port 12345 for example but the same second ip, I get the desired website with http://SecondIP:12345/whatever
Running sudo netstat -nltup | grep 'Proto\|lighttpd\|nginx\|dnsmasq\|dhcpcd\|pihole-FTL'
returns the following: (with Nginx set to listen to port 80)
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 34666/pihole-FTL
tcp 0 0 172.16.1.3:80 0.0.0.0:* LISTEN 45428/nginx: master
tcp 0 0 172.16.1.2:80 0.0.0.0:* LISTEN 36738/lighttpd
tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 34666/pihole-FTL
tcp6 0 0 ::1:4711 :::* LISTEN 34666/pihole-FTL
tcp6 0 0 :::80 :::* LISTEN 36738/lighttpd
tcp6 0 0 :::53 :::* LISTEN 34666/pihole-FTL
udp 0 0 0.0.0.0:53 0.0.0.0:* 34666/pihole-FTL
udp 0 0 0.0.0.0:67 0.0.0.0:* 34666/pihole-FTL
udp6 0 0 :::53 :::* 34666/pihole-FTL
Which shows that both nginx and pihole are listening on their own ip's respectively, but still pihole seems to be blocking port 80 on the whole interface. *
Is there a way to set it to only listen on the desired IP and not interface? If not, do I need to create some kind of a virtual interface for nginx?
Also I'm kind of confused with the external.conf
of lighttpd
, do I need to copy the whole lighttp.conf
into it and add the desired line or is it sufficient to only type in the line I want added/changed? Didn't really find anything on the web for that.
*IPv6 is not the problem as this is disabled in nginx
I tried quite a long time and went to read multiple blogs/tutorials about this too and did the same on my setup but it still won't work, but not loosing hope just yet so I'm hoping to get some clarification on here