go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  Side Notes
 
Subject: Side Notes
Author: AwsEC2
In response to: A working case for name-based virtual hosting
Posted on: 08/29/2012 09:07:34 PM

1) The settings should be

# 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 /home/ec2-user/example2.com/html

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

</VirtualHost>


2) Error Forbidden: http://www.example1.com/ returns the followings
Forbidden

You don't have permission to access / on this server.

Apache/2.2.22 (Amazon) Server at www.example1.com Port 80


By default, the folder /home/ec2-user comes with the permission rwx------. Even though you have made all your document root /home/ec2-user/example1.com/html accessible by 'others' via rwxr-xr-x, http://www.example1.com/index.html will be forbidden. You have to allow the read permission from the very top node.

 + -- home                    rwxr-xr-x  root
    + -- ec2-user             rwxr-xr-x  ec2-user
       + -- example1.com      rwxr-xr-x  ec2-user
          + -- html           rwxr-xr-x  ec2-user
             - -- index.html  rwxr-xr-x  ec2-user
       + -- example2.com      rwxr-xr-x  ec2-user
          + -- html           rwxr-xr-x  ec2-user
             - -- index.html  rwxr-xr-x  ec2-user



3) For testing purpose, you can fake the DNS from the local file

Location: C:\Windows\System32\drivers\etc\hosts
# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

123.123.123.123    example1.com    www.example1.com
123.123.123.123    example2.com    www.example2.com


Apparently, it works only from your local machine.

Type into your browser: http://www.example1.com, you should get response similar like:
This is content from index file for www.example1.com


 

> On 10/18/2011 06:55:28 PM Linux wrote:

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>





References:

 


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