nixCraft Poll

Topics

Lighttpd: How do I use more than two IP address (bind) for virtual hosting?

Posted by Vivek Gite [Last updated: December 1, 2007]

Lighttpd logo

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" {
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"
}
Save and close config file. Restart the lighttpd:
# /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:

Discussion on This Article:

  1. slav0nic Says:

    good, but if i has 2 domain on 192.168.1.2 ? =)

  2. vivek Says:

    Go here. If you have more question use our forum.

  3. Kathleen J Caunter Says:

    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

  4. Nazz Says:

    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?

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!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.