Lighttpd: How do I use more than two IP address (bind) for virtual hosting?
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 nixcraft.com
IP # 2: 192.168.1.2 domain theos.in
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 nixcraft.com virtual host:
$HTTP["host"] == "www.nixcraft.com" {
server.document-root = "/home/lighttpd/nixcraft.com/http"
server.errorlog = "/var/log/lighttpd/nixcraft.com/error.log"
accesslog.filename = "/var/log/lighttpd/nixcraft.com/access.log"
}
Next use $SERVER["socket"] to bind 192.168.1.2:80 for theos.in domain:
$SERVER["socket"] == "192.168.1.2:80" {Save and close config file. Restart the lighttpd:
server.document-root = "/home/lighttpd/theos.in/http"
server.errorlog = "/var/log/lighttpd/theos.in/error.log"
accesslog.filename = "/var/log/lighttpd/theos.in/access.log"
}
# /etc/init.d/lighttpd restart
Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
You may also be interested in other helpful articles:
- Howto: Lighttpd web server setting up virtual hosting
- Can someone steal my PHP script without hacking server?
- Lighttpd rotating log files with logrotate tool
- Lighttpd run php from different host using mod_proxy / mod_fastcgi
- Force apache webserver to listen on all addresses except one ip address
Discussion on This Article:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!



good, but if i has 2 domain on 192.168.1.2 ? =)
Go here. If you have more question use our forum.
i am confused on how to fix this problem everytime i try to sumit info on a forum it states website cant display this page i dont understand what to do i am ok with computers but this problem fixer is confusing to me caan you help me please as i have important info to sumit on this forum about my custom show car and it was suppose to be sumitted by thiss weekend sun night the latest caan you please put it in simple terms i would apprecciate your help so much Kathy
I’m trying to use lighttpd with virtual hosting and different ssl certs for each host. I have one ip that is external and one virtual ip on the same machine.
I have both of the ips set, but since they are the same server, I always get the same certificate. Adding a host check doesn’t work and when I do that neither site works via ssl.
$SERVER["socket"] == “10.0.0.1:443″ {
$HTTP["host"] =~ “www.woohoo.com” {
ssl.engine = “enable”
ssl.pemfile = var.confdir + “/www. woohoo.com.ext.pem”
ssl.ca-file = var.confdir + “/gd_intermediate.crt”
server.name = var.confdir + “/www.woohoo.com”
}
}
$SERVER["socket"] == “xx.xxx.xxx.xxx:443″ {
$HTTP["host"] =~ “www.woohoo2.com” {
ssl.engine = “enable”
ssl.pemfile = var.confdir + “/www.woohoo2.com.ext.pem”
ssl.ca-file = var.confdir + “/gd_intermediate.crt”
server.name = var.confdir + “/www.woohoo2.com”
}
}
I guess it won’t work with virtual ips. Anyone know about this?