Link to home
Start Free TrialLog in
Avatar of jchilders_98
jchilders_98

asked on

What's wrong with my VirtualHosts configuration?

Please help: my Apache web server resolves www.domain2.org to www.domain1.com in spite of the configuration in my httpd.conf (see below). More specifically, when entering www.domain2.org into browser, it brings the index.html from the documentroot of www.domain1.com. How can this be so?

>> From httpd.conf:
# Virtual host Default Virtual Host
NameVirtualHost 68.110.nnn.nnn

<VirtualHost *:80>
  ServerName www.domain1.com
  ServerAlias domain1.com *.domain1.com
  DocumentRoot /var/www/html/ch
  ServerSignature email
  DirectoryIndex  index.php index.html index.htm index.shtml
#  LogLevel  warn
#  HostNameLookups off
</VirtualHost>

<VirtualHost *:80>
  ServerName www.domain2.org
  ServerAlias domain2.org *.domain2.org
  DocumentRoot /var/www/html/fl
  DirectoryIndex  index.php index.html index.htm index.shtml
</VirtualHost>
Avatar of jchilders_98
jchilders_98

ASKER

As I continue to work on this... what should my etc/hosts file look like; ie. do I need:

  127.0.0.1 domain1 www.domain1.com
  127.0.0.1 domain2 www.domain2.org


??

Thanks in advance for any help...
you only need to work with your host file if your sites are only meant to be seen from that machine, ie. if all machines need to see the sites you would want a DNS Server, if all your internal machines need see the site you'd want to work with some static dns entries in your firewall or router..
Shouldn't NameVirtualHost be :

NameVirtualHost *:80

in order to match your VirtualHost blocks ?
Ignore my stupid answer, I just got up and didn't fully read the question, all I saw was HOST file....
I have tried the NameVirtualHost in various configurations including with the *:80 and without, the static IP address (68...), the internal fixed IP (192....); both in the NameVirtualHost and the <VirtualHost ... directives.

Sigh. Still stymied.

Could this be a permissions issue? How can I check to make sure all my file/directory permissions are setup right? Do I need a <Directory block within the <VirtualHost block?
Weird... Anything special in the server logs ? Else, what browser are you using to make the tests ?
I checked the error_log file and found a complaint from mod_unique_id. I disabled it and things progressed. Now, I get the following error when I try to connect to one of my virtual hosts:

>> 400 Bad Request
>> Your browser sent a request that this server could not understand.
>> Reason: You're speaking plain HTTP to an SSL-enabled server port.
>> Instead use the HTTPS scheme to access this URL, please.

My VirtualHosts configuration is now:

  NameVirtualHost *

 <VirtualHost *>
  ServerName www.domain1.com
  DocumentRoot /var/www/html/ch
  ServerSignature email
  Loglevel warn
  HostNameLookups off

  <Directory "var/www/html/ch">
    DirectoryIndex index.php index.html index.htm
    Options +Indexes Multiviews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    Deny from none
   </Directory>
 </VirtualHost>

I have tried setting the ../ch directory and contents to be owned by root.root, apache.apache, nobody.apache, nobody.nobody and it makes no difference. The dir and files are all chmodded to 777.
FOUND THE ANSWER

I changed the name of the file:

    /etc/httpd/conf.d/ssl.conf

to:

    ssl.txt

thereby disabling SSL (which I do NOT want) and everything started working. Hope this helps somebody.

JC
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial