• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

SOLVED! - Difficulties with Apache 2.0 and Name Based Virtual Hosts

Netopia

Diamond Member
Hey Everyone!,

I've tried looking at all the documentation I can find, I've editted and re-editted my config file over and over again, I've double checked the paths over and over.... I'm at a loss. So... let me tell the things that I know and if anyone can spot a glaring error for me, I would be VERY thankful!

This is on an RH9 box; the name of the box is "deacon". If I set things up with no virtual hosts, everything is beautiful and works fine. All my normal html files are in or in directories under /var/www/html. If I set it up with virtual hosts, the main page still works but If I try to get to one of the virtual hosts I get the "Test Page for the Apache Web Server on Red Hat Linux" and that's all I can get.

I setup a different partion mounted as /share where I hope to put a number of different webpages, each with virtual domains and also ftp folders for those domains (different subject). Under the share folder I made a folder named "web" and under that I made folders "vh1" , "vh2" and "vh3" to test the setup and usage of the virtual hosts (thus vh1, vh2 ...etc). I made a web page (index.html) for each one that just has VH1.MYDOMAIN.COM or VH2...etc so that I can tell if I'm resolving to the right directory on the server.

I have updated my DNS entries for the one domain I have (which I'll refer to as "mydomain") and all of them resolve to the single IP address just fine. The subdomains that I'm practicing with are:

deacon.mydomain.com
vh1.mydomain.com
vh2.mydomain.com
vh3.mydomain.com

Here are excerpts from my httpd.conf file... I've only been trying to set up vh1 so far:




Listen *:80

User apache
Group apache

ServerName deacon.mydomain.com

UseCanonicalName off

DocumentRoot "/var/www/html"

NameVirtualHost *:80

<VirtualHost *:80>
ServerName deacon.mydomain.com
ServerAlias *.deacon.mydomain.com
DocumentRoot /var/www/html
ServerAdmin postmaster@mydomain.com
ServerSignature email
DirectoryIndex index.php index.html index.htm index.shtml
LogLevel debug
HostNameLookups on
</VirtualHost>


<VirtualHost *:80>
ServerName vh1.mydomain.com
ServerAlias *.vh1.mydomain.com
DocumentRoot /share/web/vh1
ServerAdmin postmaster@mydomain.com
ServerSignature email
DirectoryIndex index.php index.html index.htm index.shtml
LogLevel debug
HostNameLookups on
</VirtualHost>





The reason I designate *:80 is that SSL appears to be running and if I just put "*" by itself I get SSL error pages when I browse. BTW... how does one turn ssl off?

TO ANYONE WHO HAS READ THIS FAR

Thank you! Just reading through all that is a chore and I appreciate your efforts whether you can help me or not!

Joe
 
Only knowing 1.3, i'm not sure how much help I can be.

IMHO you shouldn't need the ":80" part.
Unless your client is specifying https in the url, or :443 at the end of the domain, it won't matter that SSL is running.

What do you get when you "tail /var/log/httpd/error_log" ?

bart
 
Hmmmm ... try the following format. I have it running on my server and it's fine.

Virtualhost 10.1.1.100 <-- IP address of the system

<VirtualHost 10.1.1.100>
Servername xxx.xxx.xxx
Documentroot /pathtoyourfiles
</VirtualHost>
 
Hmmmm ... try the following format. I have it running on my server and it's fine.

Virtualhost 10.1.1.100 <-- IP address of the system

<VirtualHost 10.1.1.100>
Servername xxx.xxx.xxx
Documentroot /pathtoyourfiles
</VirtualHost>

Nope... same results. 🙁

Joe
 
turn of canonicalnames the server will then repsond to the servername directive. in each virtual host put use canonicalname off its sommit like that check your httpd files put its defianltey canonicalname your after.
 
UseCanonicalName directive already set to off.

I wonder what the mystery is? This is really strange, isn't it?

Joe
 
Originally posted by: Netopia
Hmmmm ... try the following format. I have it running on my server and it's fine.

Virtualhost 10.1.1.100 <-- IP address of the system

<VirtualHost 10.1.1.100>
Servername xxx.xxx.xxx
Documentroot /pathtoyourfiles
</VirtualHost>

Nope... same results. 🙁

Joe

Did you try just putting those 4 lines in and removing everything else inside your previous directive?

i.e. Hostnamelookup On - ServerAlias *.deacon.mydomain.com



 
Originally posted by: Netopia
UseCanonicalName directive already set to off.

I wonder what the mystery is? This is really strange, isn't it?

Joe

according to the httpd.conf yo posted it is not

VirtualHost *:80>
ServerName deacon.mydomain.com
ServerAlias *.deacon.mydomain.com
DocumentRoot /var/www/html
ServerAdmin postmaster@mydomain.com
ServerSignature email
DirectoryIndex index.php index.html index.htm index.shtml
LogLevel debug
HostNameLookups on
</VirtualHost>

It has to be tunred off on a per virtualhsot basis not just server. at server level you are only doing it for the default site not the virtual hosts.
 
It has to be tunred off on a per virtualhsot basis not just server. at server level you are only doing it for the default site not the virtual hosts.

Does it have to go anywhere special in the directive or is it ok as long as it is in there anywhere?

Joe
 
here is my functioning apache 2.0 virt host section:

This is at the very end of httpd.conf, regarding virtual hosting.


VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
<VirtualHost *>
ServerAdmin service@xxx.com
DocumentRoot /usr/local/www/xxxdocs
ServerName www.xxx.com
# ErrorLog /var/log/dummy-host.example.com-error_log default lines, commented out if not used
# CustomLog /var/log/dummy-host.example.com-access_log common
</VirtualHost>

<VirtualHost *>
ServerAdmin service@xxx.com
DocumentRoot /usr/local/www/yyydocs
ServerName www.yyy.com

</VirtualHost>

Replace xxx and yyy with the right values and paths, and you are good to go.

 
anywhere in the vhost will be fine. I had a load of probs with 2.0 over 1.3 regarding vhosts it seems much more awkward to setup. Did you get it up n running?

 
Along the line something happened and httpd would no longer restart, listing two or three errors dealing with SSL and not being able to bind "0.0.0.0 to :443" or something close to that. Since I am just learning and practicing, after a half hour of putting back in original .conf files and not being able to get it working again, I just reloaded RH9 but made sure NOT to install the mod_'s for Apache this time...... since I'm only learning and don't really know what I'm doing yet they would just be running for no reason anyway.

I hope to go at it again today and tomorrow.

I do have an additional question though... do sub-domains qualify for use as virtual domains? Does it just look at the domain name or the whole URL when it directs you to a page. The reason I ask is that it occurred to me that maybe the way I've got it set up for practicing is messing me up. I've got www.mydomain.com but then I use subdomains for the virtuals... i.e. vh1.mydomain, vh2.mydomain... etc. They all have proper DNS and can resolve from anywhere on the internet, but I'm not 100% on how Apapche uses the URL.

Thanks, as always, for all of your (plural) help!

Joe
 
Actually, make sure you have a line that reads

NameVirtualHost 10.0.0.1:80
or
NameVirtualHost *

I don't believe that *:80 will work, but I could be mistaken.

More Info Here

On your last question, it regards the entire url. You could have a virtualhost for this.is.a.long.subdomain.for.my.domain.com if you wanted, and in fact, I have had several sub sub domains configured in Apache (1.3).

 
A little off topic, but as I started back into the http.conf, I enabled home directories for the first time and was amazed that it actually worked just fine! Hey... one little victory! 🙂

Now... onto the virtual domains.

Joe
 
Actually, make sure you have a line that reads

NameVirtualHost 10.0.0.1:80
or
NameVirtualHost *

I don't believe that *:80 will work, but I could be mistaken.

THAT WAS IT! DAMN! I feel stooooooooopid! I went through those instructions on the Apache page again and again and THAT was the very FIRST line of the example!

DOH!

Thank you all very much for aiding me. Now I have to learn as much as possible to help the next knucklehead like me who comes along!
rolleye.gif


Joe
 
Back
Top