Sub Domains & Virtual Hosts [Closed - Unsolved]
I'm running Apache 2.0.51 r1 on a Gentoo Linux box ver 2.4.25 and what I would like to do is host individual websites for some user accounts using sub-domains (ex. foo.somesite.sytes.net for user foo). My No-IP account is upgraded to Enhanced.
At the moment, foo's website can be accessed through the default per-user directory somesite.sytes.net/~foo/ and the default website is simply accessed at somesite.sytes.net. This is what I have done so far: - I have enabled wildcards for the domain somesite.sytes.net (which is port redirected to 81) - In the commonapache.conf file (located in /etc/apache2/conf) I have added the following for virtual hosting: Code:
NameVirtualHost * I've looked around in various linux forums and the apache website to figure out how to fix this and obtain the results that I am looking for, but as far as I know, everything I've done is correct. But since I am not getting the result I want, something must be wrong. Please help, I've spent so much time already on this. Thanks. |
Ugh, after 3 hours, still nothing!! :x
Other information that could prove useful in troubleshooting: - In apache2.conf ServerName is set to somesites.sytes.net - In commonapache.conf I switched the UseCanonicalName Off - In my /etc/hosts file I added 192.168.0.1 www.somesites.sytes.net 192.168.0.1 foo.somesites.sytes.net Any ideas? |
Virtual hosts can be a real PIA sometimes. I've had instances where the wildcard didn't' work and I'd have to use the IP. For instance:
<VirtualHost 192.168.1.12> ServerName www.foo.com DocumentRoot /var/www/foo </VirtualHost> Here is a paste from my /usr/local/apache2/conf/httpd.conf file: <VirtualHost *> ServerName www.foo.com ServerAlias foo.com ServerPath /foo/ DocumentRoot /usr/local/foo ErrorLog logs/foo.com-error_log </VirtualHost> Also, I generally use bind instead of messing with the hosts file. You might be able to test your config with the IP. For instance 192.168.1.12 would resolve differently than 192.168.1.12/foo/ Another hint is to run apachectl configtest. It might point you at any errors in your conf file. |
I've tried both the * and explicit ip address and neither one made a difference. Also, apache2clt showed that there were no syntax errors.
Further investigation lead me to try to figure out what the request header was sending to figure out why no match to any of the virtual host names was occuring (thus resulting in the default host serving the pages). I started with the access_log and found that the referrer address was blank on every access to the subdomain. Is this how it should be? Code:
192.168.0.2 - - [13/Oct/2004:17:31:51 +0000] "GET / HTTP/1.1" 200 142 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" If I can figure out why this is occuring (if it is not normal) then maybe this can help me to figure out the virtual host matching problem. Anyone have any ideas? |
Disregard my last post. The dash "-" in the log where the referer is supposed to be is because there was no referer since the browser got the URL directly. The original problem still persists.
|
Some peculiar results to note:
Code:
NameVirtualHost * I'm gonna keep playing around with this to see what's really going on. Does anyone have any thoughts on this? |
Well, I'm curious to whether the subdomain and the domain resolve from the local machine and any remote machines you might be trying. Does ping work?
ping www.somsite.sytes.net ping www.sytes.net Also, since you mentioned port 81 try changing your NameVirtualHost to your IP:Port e.g. NameVirtualHost 192.168.0.2:81 |
Quote:
2) Code:
NameVirtualHost 192.168.0.1:81 Problem still persists |
I'm sorry I'm not an expert at this.. I usually get mine working by doing a lot of tinkering and a lot of apache restarting in between. The only other thing I can think of is evening it up a bit between the two by having the same entries (e.g. ServerAlias, ServerPath, etc)
Maybe somebody else from the community can help out. :o( |
Revelation!
K i modified my apache configuration to display for me the host header used for the virtual host matching and my logs reveal that it is always my ip and port regardless of what subdomain the client requests (ex. foo.somesite.sytes.net, www.somesite.sytes.net, etc.). Ideally, if the client types foo.somesite.sytes.net, that is what should be in the host header so that the virtualhost matching correctly serves the right page. But somehow, the port redirection is translating foo.somesite.sytes.net to my IP in the host header. Is there a way to preserve the subdomain information in the host header and still use port redirection so that virtual hosting will work? Problem still persists |
I'm not getting a lot of luv from the community on solving this problem so i'm just gonna give up and close this thread. If you have any insight please feel free to contribute your posts :)
|
I've been having this same problem where the only way i can get my three virtual name based hosts to work is to have the ordering like so:
NameVirtualHost *:80 <VirtualHost *:80> ServerName mpi.televisiontakeover.com DocumentRoot /usr/www/mpi </VirtualHost> <VirtualHost *:80> ServerName speech.televisiontakeover.com DocumentRoot /usr/www/speech </VirtualHost> <VirtualHost *:80> ServerName www.televisiontakeover.com DocumentRoot /usr/www/takeover </VirtualHost> any other ordering doesn't work. What should i do? |
All times are GMT -5. The time now is 07:04 AM. |