How Apache name-based virtual host works with public IP address?

5,245

The http header will contain the host. In your example above, this would be www.example.com or www.example1.com. This host header is read by apache and then used to send the client the correct vhost.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23

http://httpd.apache.org/docs/2.2/vhosts/examples.html

Share:
5,245

Related videos on Youtube

userpal
Author by

userpal

Updated on September 18, 2022

Comments

  • userpal
    userpal over 1 year

    I am new to Apache web server. When we configure Apache web server, we have the options of setting name-based virtual host.

    Based on my understanding, when a user type in a domain name www.example.com in a web browser, it will connect to a DNS server which will convert the domain name to a (public) IP address. Then, the web browser will connect to the web server using the IP address.

    Now, let's say I have a server with a public IP address, a.a.a.a. I have registered 2 domain names, www.example.com and www.example1.com. Both of these 2 domain names are pointing to the same IP address, a.a.a.a. So, when user types in www.example.com or www.example1.com in his web browser, the DNS server will point them to the IP address a.a.a.a.

    I have configured name-based virtual host according to the user guide at this web site.

    However, what I don't understand is: Since the DNS server already converted domain names to IP address, all users will connect to the web server using IP address a.a.a.a. How Apache knows whether the user is using www.example.com or www.example1.com in their web browser?