Using More Than Two IPs (bind)

Virtual hosting is nothing but the provision of Web server hosting services so that a company (or individual) doesn’t have to purchase and maintain its own Web server and connections to the Internet.

Lighttpd does support or allows you to bind more than two IP address simultaneously using $SERVER[“socket”]..

For example,
IP # 1: 192.168.1.1 domain domain.com
IP # 2: 192.168.1.2 domain domain2.com

Open lighttpd.conf file:
# vi /etc/lighttpd/lighttpd.conf

First use server.bind and server.port to setup 192.168.1.1 IP
server.port = 80
server.bind = "192.168.1.1"

Now define domain.com virtual host:
$HTTP["host"] == "www.domain.com" {
server.document-root = "/home/lighttpd/domain.com/http"
server.errorlog = "/var/log/lighttpd/domain.com/error.log"
accesslog.filename = "/var/log/lighttpd/domain.com/access.log"
}

Next use $SERVER[“socket”] to bind 192.168.1.2:80 for domain2.com domain:
$SERVER["socket"] == "192.168.1.2:80" {
server.document-root = "/home/lighttpd/domain2.com/http"
server.errorlog = "/var/log/lighttpd/domain2.com/error.log"
accesslog.filename = "/var/log/lighttpd/domain2.com/access.log"
}

Save and close config file. Restart the lighttpd:
# /etc/init.d/lighttpd restart

Leave a Reply

Your email address will not be published. Required fields are marked *