Apache name based vhost??

Place to discuss Fedora and/or Red Hat

Apache name based vhost??

Postby ZiaTioN » Tue May 27, 2003 7:08 pm

I recently setup some vhosts in my web server and for some reason my subhosts will not resolve. I have issued the "dig" command on each and they seem to be resolving fine and I even got ahold of my domain name company and they checked their side and said everything looked fine.

As of now I have 3 domain names. My main one is resolving fine and I can access my web page easily. The other 2 however will not be accessed. I have my main page as the first vhost on the httpd.cong file and the other 2 in the exact same syntax and format following next in line. I have also pinged each vhost and I get a response from all of them.

Anyone have any ideas why my hosts would seem to be resolving fine but the page still will not load? I thought maybe the TTL was set too low in my browser and the pages were taking longer to resolve but this isnt the case because my main page URL is being resolved on the same DNS as my 2 subhosts are and the main loads fine.

Here is what my vhosts look like:

Code: Select all

NameVirtualHost 192.168.0.4

<VirtualHost *>
    # primary host
    ServerAdmin [email]ziation@yahoo.com[/email]
    DocumentRoot /home/master/webroot
    ServerName ******
</VirtualHost>

<VirtualHost *>
    # Main Host
    ServerAdmin ziation@yahoo.com
    DocumentRoot /home/master/webroot/mainhost
    ServerName www.mainhost.com
</VirtualHost>

<VirtualHost *>
    # First Sub Host
    ServerAdmin ziation@yahoo.com
    DocumentRoot /home/master/webroot/firstsubhost
    ServerName www.firstsubhost.mainhost.com

<VirtualHost *>
    # Second Sub Host
    ServerAdmin ziation@yahoo.com
    DocumentRoot /home/master/webroot/secondsubhost
    ServerName www.secondsubhost.mainhost.com
</VirtualHost>



Each subhost has the main host in it's URL. This is the very nature of a subhost (in case that confused you).

But all looks well to me. The first vhost I have up top is a vhost I added for folks with old browser or browsers that do not support name based vhost re-direction so that should not have any bearing on my problem at hand.


If anyone has any experience with this please hook me up!!!

Thanx...



Ok here are the warnings I am getting when I start my web server with the -S option to verify my vhost setup:

Code: Select all
[Tue May 27 18:02:15 2003] [alert] httpd: Could not determine the server's fully qualified domain name, using 192.168.0.4 for ServerName
[Tue May 27 18:02:15 2003] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Tue May 27 18:02:15 2003] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Tue May 27 18:02:15 2003] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Tue May 27 18:02:15 2003] [warn] NameVirtualHost 192.168.0.4:80 has no VirtualHosts
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:


Overlap on port 80?? I know this does not mean that I cannot run multiple hosts on the same port does it?
ZiaTioN
administrator
administrator
 
Posts: 460
Joined: Tue Apr 08, 2003 3:28 pm

Postby Void Main » Tue May 27, 2003 9:42 pm

A few things:

1) Change the "NameVirtualHost 192.168.0.4" to "NameVirtualHost *".
2) Could be a typo but your third vhost is missing a "</VirtualHost>"
3) I have my "ServerName" directive set to "ServerName myhost.internaldomain.home:80" where in your case "myhost.internaldomain.home" would be in your /etc/hosts as 192.168.0.4.
4) I also set "UseCanonicalName Off" which I believe is the default.

That should work for Apache 2.0.x. Is this RH9? I have a few vhosts on this server and here's my httpd.conf if you want to look at it:

http://voidmain.is-a-geek.net/files/httpd.conf

I have sanitized it slightly but nothing functionally has been changed.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby ZiaTioN » Wed May 28, 2003 7:42 am

Yeah it seems that I had www in my ServerName fields at first then I took them out and used just the domain names without www and they all seemed to work. But when I add the www back, they do not. I added some server aliases so they would resolve on either address (with or without the www) but they do not resolve with the www.

Could this be a dns problem??
ZiaTioN
administrator
administrator
 
Posts: 460
Joined: Tue Apr 08, 2003 3:28 pm

Postby Void Main » Wed May 28, 2003 8:00 am

Your server and any client that you want to be able to get to your "www.somehost.somedomain.com" *must* be able to resolve that name. This is usually done via DNS but you could just have host entries in your /etc/hosts for the names, the clients would also need the host entries. Of course DNS is much easier. If on your server and the clients you can nslookup/host/dig/ping by name the "www.somehost.somedomain.com" and get the proper IP address then it should work.

I don't believe I have ever done a vhost with four name parts although in this example "www.somehost" would be the hostname and "somedomain.com" would be the domain. I don't know if having a "." in the hostname would cause a problem in the vhost but I don't believe it should be a problem.

Can you ping all the names you are trying to use on both your server and on the clients? And do you get the proper associated public IP address? If you can then it most certainly is not a DNS issue, but a misconfiguration of your server.

[edit]
I just configured two more virtual hosts on my void server with absolutely no problems. I created a "myhost.voidmain.home" and a "www.myhost.voidmain.home" in my local DNS server and created virtual hosts for them in Apache and they both go to their respective DocumentRoot directories, no fuss. I would have to see your httpd.conf and /etc/hosts files before I could trouble-shoot it any farther.
[/edit]
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby ZiaTioN » Wed May 28, 2003 3:26 pm

Yah i figured it out. I had to create cnames on my dns server for the registered URL's that I had.

The registered domain names were without the www.

All I had to do was create some ServerAliases and then create cnames for those domain names..

Thanx anyway
ZiaTioN
administrator
administrator
 
Posts: 460
Joined: Tue Apr 08, 2003 3:28 pm

Postby Void Main » Wed May 28, 2003 3:39 pm

Yeah, not actually creating the hostnames in DNS would be a problem. :)
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA


Return to Fedora/Red Hat

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron