For example if you want to setup like below:
10.0.0.10:80 --> lighttpd (for Pi-Hole)
10.0.0.20:80 --> nginx (your other web apps via HTTP)
10.0.0.20:443 --> nginx (your other web apps via HTTPS)
-
In the "interfaces" file, you add alias interface "eth0:0" with second IP:
*replace IP address and netmask to suit your needs.{
echo
echo 'auto eth0:0'
echo 'allow-hotplug eth0:0'
echo 'iface eth0:0 inet static'
echo ' address 10.0.0.20'
echo ' netmask 255.255.255.0'
} | sudo tee -a /etc/network/interfaces -
Bring up the new interface, including verbose logging, with:
sudo ifup -v eth0:0
- Configure lighttpd to listen to the eth0 interface IP address:
echo 'server.bind = "10.0.0.10"' | sudo tee -a /etc/lighttpd/lighttpd.conf
- Reload lighttpd settings:
sudo service lighttpd reload
- Have nginx listen to the eth0:0 interface IP address by adding/changing below in "
nginx.conf
":
-
Not sure how to configure nginx as I dont have and have never used before.
listen 10.0.0.20:80
listen 10.0.0.20:443
- Reload nginx settings:
sudo service nginx restart
- Check the relevant daemons with:
sudo netstat -nltup | grep 'Proto\|lighttpd\|nginx\|dnsmasq\|dhcpcd\|pihole-FTL'
Below the output for netstat as example:
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 50/pihole-FTL
tcp 0 0 10.0.0.10:80 0.0.0.0:* LISTEN 100/lighttpd
tcp 0 0 10.0.0.20:80 0.0.0.0:* LISTEN 200/nginx -g daemo
tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 300/dnsmasq
tcp 0 0 10.0.0.20:443 0.0.0.0:* LISTEN 200/nginx -g daemo
tcp6 0 0 :::53 :::* LISTEN 300/dnsmasq
udp 0 0 0.0.0.0:53 0.0.0.0:* 300/dnsmasq
udp 0 0 0.0.0.0:68 0.0.0.0:* 400/dhcpcd
udp6 0 0 :::53 :::* 300/dnsmasq
And here is explained how to disable IPv6 if conflicting:
Very important note, if using Pi-Hole as DHCP server, the only way to not have dnsmasq mix up the interfaces is to hash out all static IP address assignments for the "eth0" interface in the "dhcpcd.conf" file eg:
sudo nano /etc/dhcpcd.conf
#interface eth0
# static ip_address=10.0.0.10/24
# static routers=10.0.0.1
# static domain_name_servers=10.0.0.1
And move the static IP address assignment for "eth0" to the "interfaces" configuration file (hash out existing eth0 line):
sudo nano /etc/network/interfaces
#iface eth0 inet manual
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 10.0.0.10
netmask 255.255.255.0
gateway 10.0.0.1
And make sure a DNS nameserver is set in the "resolv.conf" file eg:
sudo nano /etc/resolv.conf
# Local Pi-Hole DNS service
nameserver 127.0.0.1