Hi,
I have created 3 virtual hosts within my virtual machine.
The DocumentRoot for two of the virtual machines are located in
/var/www/vhosts. The name of these two virtual hosts (ServerName) are beta.example.com & example.com. The index.html contents for both these servers are "COFFEE!" and "COKE!" respectively.
The 3rd virtual host is located in a directory called /website. I created an index.html for this virtual host in /website with the content "OMG SO NON STANDARD".
The SELinux setting for the /website directory was originally :
Code:
# ls -Z / | grep website
drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 website
# ls -Z /website/
-rw-r--r--. root root unconfined_u:object_r:default_t:s0 index.html
Changed it to :
Code:
# chcon --reference=/var/www /website/
# ls -Z / | grep website
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 website
# chcon --reference=/var/www/vhosts/example.com/index.html /website/index.html
Even after doing these changes, I am not able to see any output when I do :
Code:
# curl non.example.com
It produces error like 'host not found'.
I then add all three virtual hosts beta.example.com, example.com and non.example.com into /etc/hosts, the same line as localhost.
I then restart httpd, and when I do the 'curl' command :
Code:
# curl non.example.com
COFFEE!
It produces output "COFFEE!". I then move the beta.example.com & example.com to a different directory and restart httpd, and then I get the output desired from curl :
Code:
# curl non.example.com
OMG SO NON STANDARD
Today, I remove the beta.example.com, example.com and non.example.com from /etc/hosts, and restart httpd, and I still get the output same as above :
Code:
# curl non.example.com
OMG SO NON STANDARD
My question is, what is the correct way to get virtual hosts to produce the output desired from index.html without getting any errors. Is it really required to add the VirtualHost "ServerName" (in this case example.com, beta.example.com, non.example.com) in /etc/hosts?
If so then why does using curl on non.example.com give the output COFFEE! which is the content of beta.example.com?