Skip to main content
edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264
deleted 1 character in body
Source Link

I have 2 virtual hosts loaded from 2 separate conf files in /etc/httpd/conf.d/ when I point my browser to vhost1.test.com it loads the proper index.html as does vhost2.test.com. However the web server now responds with the 2nd vhost as the servers wildcard domain, if I make a dns entry for blahfoo.test.com the page for vhost2 will load. If I remove the configuration for vhost2 the same behavior now happens for vhost1. What in my configuration is causing the last virtual server loaded to become a wildcard domain? With this configuration apache is also ignoring the default document root of /var/www/html when I point my browser to test.com and instead loading the wildcard. Without either vhost.conf loaded the documents in /var/www/html load as expected.

vhost1.conf

<VirtualHost *:80>
DocumentRoot /vhost1
ServerName vhost1.test.com
ErrorLog logs/vhost1-error_log
CustomLog logs/vhost1-access_log common
<Directory "/vhost1">
order deny,allow
Require all granted
Allow from localhost 127.0.0.1 192.168.
</Directory>

vhost2.conf

<VirtualHost *:80>
DocumentRoot /vhost2
ServerName vhost2.test.com
ErrorLog logs/vhost2-error_log
CustomLog logs/vhost2-access_log common
<Directory "/vhost2">
order deny,allow
Require all granted
Allow from localhost 127.0.0.1 192.168.
</Directory> 

I have 2 virtual hosts loaded from 2 separate conf files in /etc/httpd/conf.d/ when I point my browser to vhost1.test.com it loads the proper index.html as does vhost2.test.com. However the web server now responds with the 2nd vhost as the servers wildcard domain, if I make a dns entry for blah.test.com the page for vhost2 will load. If I remove the configuration for vhost2 the same behavior now happens for vhost1. What in my configuration is causing the last virtual server loaded to become a wildcard domain? With this configuration apache is also ignoring the default document root of /var/www/html when I point my browser to test.com and instead loading the wildcard. Without either vhost.conf loaded the documents in /var/www/html load as expected.

vhost1.conf

<VirtualHost *:80>
DocumentRoot /vhost1
ServerName vhost1.test.com
ErrorLog logs/vhost1-error_log
CustomLog logs/vhost1-access_log common
<Directory "/vhost1">
order deny,allow
Require all granted
Allow from localhost 127.0.0.1 192.168.
</Directory>

vhost2.conf

<VirtualHost *:80>
DocumentRoot /vhost2
ServerName vhost2.test.com
ErrorLog logs/vhost2-error_log
CustomLog logs/vhost2-access_log common
<Directory "/vhost2">
order deny,allow
Require all granted
Allow from localhost 127.0.0.1 192.168.
</Directory> 

I have 2 virtual hosts loaded from 2 separate conf files in /etc/httpd/conf.d/ when I point my browser to vhost1.test.com it loads the proper index.html as does vhost2.test.com. However the web server now responds with the 2nd vhost as the servers wildcard domain, if I make a dns entry for foo.test.com the page for vhost2 will load. If I remove the configuration for vhost2 the same behavior now happens for vhost1. What in my configuration is causing the last virtual server loaded to become a wildcard domain? With this configuration apache is also ignoring the default document root of /var/www/html when I point my browser to test.com and instead loading the wildcard. Without either vhost.conf loaded the documents in /var/www/html load as expected.

vhost1.conf

<VirtualHost *:80>
DocumentRoot /vhost1
ServerName vhost1.test.com
ErrorLog logs/vhost1-error_log
CustomLog logs/vhost1-access_log common
<Directory "/vhost1">
order deny,allow
Require all granted
Allow from localhost 127.0.0.1 192.168.
</Directory>

vhost2.conf

<VirtualHost *:80>
DocumentRoot /vhost2
ServerName vhost2.test.com
ErrorLog logs/vhost2-error_log
CustomLog logs/vhost2-access_log common
<Directory "/vhost2">
order deny,allow
Require all granted
Allow from localhost 127.0.0.1 192.168.
</Directory> 
Source Link

apache configuration problems, last vhost loaded becomes wildcard domain

I have 2 virtual hosts loaded from 2 separate conf files in /etc/httpd/conf.d/ when I point my browser to vhost1.test.com it loads the proper index.html as does vhost2.test.com. However the web server now responds with the 2nd vhost as the servers wildcard domain, if I make a dns entry for blah.test.com the page for vhost2 will load. If I remove the configuration for vhost2 the same behavior now happens for vhost1. What in my configuration is causing the last virtual server loaded to become a wildcard domain? With this configuration apache is also ignoring the default document root of /var/www/html when I point my browser to test.com and instead loading the wildcard. Without either vhost.conf loaded the documents in /var/www/html load as expected.

vhost1.conf

<VirtualHost *:80>
DocumentRoot /vhost1
ServerName vhost1.test.com
ErrorLog logs/vhost1-error_log
CustomLog logs/vhost1-access_log common
<Directory "/vhost1">
order deny,allow
Require all granted
Allow from localhost 127.0.0.1 192.168.
</Directory>

vhost2.conf

<VirtualHost *:80>
DocumentRoot /vhost2
ServerName vhost2.test.com
ErrorLog logs/vhost2-error_log
CustomLog logs/vhost2-access_log common
<Directory "/vhost2">
order deny,allow
Require all granted
Allow from localhost 127.0.0.1 192.168.
</Directory>