Forum Moderators: phranque

Message Too Old, No Replies

Apache Name-Based Virtual Domain Problems

when vhost is accessed the default host always is displayed

         

urbsom

11:48 pm on Jan 27, 2004 (gmt 0)

10+ Year Member



I must first apologize if this inquiry has already been posted, but after searching for 2+ hours, I figured my chances were good that this problem has not been addressed.

First of all a bit about my environment:
Win2K w/ Apache2.0.44 & php4.2.2
Also, my server is sitting behind self-managed firewall/router which has been configured correctly to all all inbound/outbound requests.

This whole process started as I obtained a new server. My current server houses the same os and versions of apache & php. All I am trying to do is migrate my existing web environment to a new machine that sits behind the exact firewall.

For some strange reason, my virutal hosts are not working. I have ONE IP and am using virtual hosts to handle one domain (call somedomain1.com) with about 10 subdomains and then another domain (call somedomain2.com) with 0 subdomains.

When I access the server via a browser with any of my urls, the same base site comes up for somedomain1.com. Before I go along too far, here are my entries tha matter in the httpd.conf file:


ServerName somedomain1.com:80
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"

NameVirtualHost *

<VirtualHost *>
ServerAdmin admin@somedomain1.com
ServerName www.somedomain1.com
ServerAlias somedomain1.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"
</VirtualHost>

<VirtualHost *>
ServerAdmin admin@somdomain1.com
ServerName a.somedomain1.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/a"
</VirtualHost>

<VirtualHost *>
ServerAdmin admin@somdomain1.com
ServerName b.somedomain1.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/b"
</VirtualHost>

<VirtualHost *>
ServerAdmin admin@somdomain1.com
ServerName c.somedomain1.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/c"
</VirtualHost>

.
.
.

<VirtualHost *>
ServerAdmin admin@somdomain1.com
ServerName i.somedomain1.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/i"
</VirtualHost>

<VirtualHost *>
ServerAdmin admin@somdomain1.com
ServerName j.somedomain1.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/j"
</VirtualHost>

<VirtualHost *>
ServerAdmin admin@somedomain2.com
ServerName www.somedomain2.com
ServerAlias somedomain2.com *.somedomain2.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/domain2"
</VirtualHost>

Since there are a few subdomain that include a .htaccess file which prompt the user for a username and password, I tried a few of them. Upon entering the url in the browser it asks for a uname/pword. I supply the correct values and hit enter. Then the browser attempts to load the base site somedomain1.com, but can quite do so becuase the files it are looking for aren't contained with in that subdomains root.

It seems to me that apache picks up the vhost, acquires the right home direcotry, but then attempts to load the index file for the base site of somedomain1.com.

I tried substituting my ip for the * in all the vhost entries and removing all but the major domain entries and still no luck. If anyone can give me a clue to what the heck is going on before I loose my sanity it would be greatly appreciated. Thanks in advance!

bakedjake

11:55 pm on Jan 27, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld, urbsom!

Try the IP address in namevirtualhost with port:

NameVirtualHost 10.10.10.1:80

Then, for all of your virtualhost entries, use the subdomain name with port:


<VirtualHost www.somedomain1.com:80>
ServerAdmin admin@somedomain1.com
ServerName www.somedomain1.com
ServerAlias somedomain1.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"
</VirtualHost>


<VirtualHost a.somedomain1.com:80>
ServerAdmin admin@somdomain1.com
ServerName a.somedomain1.com
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/a"
</VirtualHost>

etc...

urbsom

2:23 am on Jan 28, 2004 (gmt 0)

10+ Year Member



bakejake, thanks for replying so fast! I did exactly as you instructed and placed my IP:Port in the NameVirtualHost directive. Then I proceeded to put the actual url for each vhost in the VirtualHost directive. When I restarted the server I ended up with the same result. The only exception is that this time I noticed that all of the vhosts that use php are the vhosts giving me problems. Out of all the vhosts, two of them are just static html sites. These vhosts work just fine. So, I guess this means there is something going on with php when the other vhosts try to display their respective site. I looked over my php.ini file to make sure my docroot was set to the right directory and sure enough it was. Any suggestions? Thanks!

bakedjake

6:03 am on Jan 28, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



So, I guess this means there is something going on with php when the other vhosts try to display their respective site.

Let's try and nail this down. I'm using PHP with the above format for VHosts, and it's working just fine. So let's make sure we've got the VHosts working first, then we'll try and debug php.

Can you put an index.html file in each of the virtualhosts directory and try to access it? Make sure you have a different index.html per site, so you know that it's working!

urbsom

1:13 pm on Jan 28, 2004 (gmt 0)

10+ Year Member



OK, I placed a html file (named index.html) in each directory and then tried it out. As before all the vhosts display the default vhosts site except for the two that had previously been working (the all static html hosts). So, maybe my comment about it being the php was wrong. Any more ideas on how I can narrow this down?

urbsom

1:20 pm on Jan 28, 2004 (gmt 0)

10+ Year Member



Correction...none of them are working now. I don't know what it is, but right after I wrote my previous post I went back and was just double checking the urls and now, ALL of them display the default vhost. I am truely lost for words!

bakedjake

5:16 pm on Jan 28, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Are you trying this from outside your firewall?

urbsom

5:47 pm on Jan 28, 2004 (gmt 0)

10+ Year Member



No, I am trying to access the sites from another machine behind the firewall. The firewall shouldn't have anything to do with this problem. My other server, which I am trying to migrate from, also sits behind the firewall and has never had a problem.