go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  A working case for name-based virtual hosting
 
Subject: A working case for name-based virtual hosting
Author: Linux
In response to: Running multiple name-based websites on a single IP address
Posted on: 10/18/2011 06:55:28 PM

For same reason, the name-based virtual hosting on explicit IP address is not working on AWS EC2 Micro instance. But the wildcard * is working which means it is going to accept all requests to this server. Any request with unmatched domain/server name will be served by the first <VirtualHost> block, which is the default one.

# Listen for virtual host requests 
NameVirtualHost *:80

<VirtualHost *:80>
  ServerName example1.com
  ServerAlias www.example1.com
  DocumentRoot /home/ec2-user/example1.com/html
  SuexecUserGroup ec2-user ec2-user

  <Directory /home/ec2-user/example1.com/html>
    Options Indexes Includes FollowSymLinks
    AllowOverride All
  </Directory>
  
</VirtualHost>

<VirtualHost *:80>
  ServerName example2.com
  ServerAlias www.example2.com
  DocumentRoot /www/ec2-user/example2.com/html

  <Directory /home/ec2-user/example2.com/html>
    Options Indexes Includes FollowSymLinks
    AllowOverride All
  </Directory>

</VirtualHost>


 

> On 10/13/2011 08:59:31 PM Linux wrote:

Your server has a single IP address, for example, 123.123.123.123, and multiple aliases (CNAMES) point to this machine in DNS. Specifically, You want to run a web server for www.example1.com and www.example2.com on the same machine.



   example1.com  --- DNS ---|
                            |
                            |--- 123.123.123.123 --->   /home/ec2-user
                            |                            + -- /example1.com
   example2.com  --- DNS ---|                               + -- /html
                                                              - -- index.html 
                                                         + -- /example2.com
                                                            + -- /html 
                                                              - -- index.html 





Here is the corresponding settings in "/etc/httpd/conf/httpd.conf"

# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on IP addresse: 123.123.123.123
NameVirtualHost 123.123.123.123:80

<VirtualHost 123.123.123.123:80>
  DocumentRoot /home/ec2-user/example1.com/html
  ServerName example1.com
  ServerAlias www.example1.com
  
  # Other directives here

</VirtualHost>

<VirtualHost 123.123.123.123:80>
  DocumentRoot /www/ec2-user/example2.com/html
  ServerName example2.com
  ServerAlias www.example2.com

  # Other directives here
</VirtualHost>






References:

 


 
Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.