Helpful Information
 
 
Category: Development Articles
Getting More Out Of Apache (Part 1)

Thanks for the info. Now I know how people put things like "current time is: xx:xx" on their pages. Will give it a try tomorrow.

I had some problems undestatnding how to setup vitrual hosts before. Now I don't...

...your headline graphic is bad

Don't forget to modify your /etc/logrotate.d/apache file accordingly, or else your log files will keep on growing.

- Stan

My problem is with the gocha statement, in that I have numerous things defined in my httpd.conf file - such as custom error handling - will these things be nullified if I create an entry of NameVirtualHost, and if so do I then need to demarcate them as a virtual localhost ??
<br>

<br>
Thanks for the help
<br>

<br>
--JohnBlaze

Unfortunately, yes the custom error handling does go somewhat down the tubes when you are using name virtual hosts. I have run into the same problems here on my systems. I am using a variant of name virtual hosting using mod_vhost. You can specify the error-docs as "External Redirects" but if you are using SSI/PHP/CGI to generate the page the majority of the variables that you need to generate the page are tossed due to the external redirect.

I haven't spent alot of time on a workaround for it but I am sure one is possible. Especially if you start using Apatche VooDoo like mod_rewrite.

Joe Modjeski
system Architect
Northlink LLC

About 3 months ago I started looking at the features in Apache that went beyond what this article covered. I am still somewhat in shock with all that is possible inside the httpd.conf file.

Its just too bad for me that this article is about 3 months late for all that I have done. I think alot of Web Developers / System Administrators alike could use a refresher course on problem solving website pains within the Apache kernel rather than all the other 2 cent hacks we throw together in a pinch.

Joe Modjeski
System Architect
Northlink LLC

Nice article. I have 2 domain names and was wondering how I could do this. My question is this, The server is setup with one of the domain names now and is working fine. Do I have to remove this operating server's information before adding this same domain as a virtual host? Thanks a bunch in advance.
Amos

The main purpose for me reading this article was to find out how to prevent users from viewing directory listings. If someone could give me some insight on this I'd appreciate it.

- Honky

You will deny directory listing with the directory-setting

<directory "c:/apache/htdocs">
Options -Indexes
</directory>

or in an .htaccess- file ehich you put in the directory you dont want to be listed.

Your Marcello

as long as the DNS side is ok then you can put any "virtual" web server on any domain you want for example:


<!-- Code -->
<p><pre><font color=#008000><xmp>
<VirtualHost 209.20.3.201>
ServerAdmin vajra@quadratic.net
DocumentRoot /home/vajra/public_html/poperotica
ServerName www.poperotica.com
ErrorLog /var/log/httpd/www.poperotica.com-error_log
CustomLog /var/log/httpd/www.poperotica.com_log combined
</VirtualHost>

<VirtualHost 209.20.3.201>
ServerAdmin monkeyboy@spankme.org
DocumentRoot /usr/local/apache/htdocs/mboy
ServerName monkeyboy.spankme.org
ErrorLog /var/log/httpd/monkeyboy.spankme.org-error_log
CustomLog /var/log/httpd/monkeyboy.spankme.org_log combined
</VirtualHost>


<VirtualHost 209.20.3.201>
ServerAdmin david@quadratic.net
DocumentRoot /mp3
ServerName mp3.quadratic.net
ErrorLog /var/log/httpd/mp3.quadratic.net-error_log
CustomLog /var/log/httpd/mp3.quadratic.net_log combined
</VirtualHost>
</xmp></font></pre><p>
<!-- Code -->


Neat huh? the local machine thinks that it is zeus.quadratic.net (209.20.3.201)
(hmmm was that a shameless plug for my, currently broken, web sites? why yes it was..I really gotta setup my new machine ...)

david thornton

You can use -indexes in httpd.conf or in an .htaccess file to forbid it.
<br>

<br>
Also, if you want to make absolutely sure that directories listings are never viewable, then recompile Apache. On the ./configure --prefix=/apache/home ... add the directive --disable-module=autoindex to the command to have Apache compiled without the ability to show directory listings.

In section 2 of httpd.conf, you specify the configuration of the 'default web site'.

I think you can somehow configure the default site to use host header resolution, but it might be harder than it's worth.

What I do on multihost servers is set up the default web site to be a local-only website set to the name of the server machine itself and an IP of 127.0.0.1 (The local loopback address), then add all the name-based virtual hosts in section three.

Most of the settings defined for the default site in section 2 of httpd.conf are inherited by the virtual hosts defined in section three. Not all of them, but most.

Check the Apache module documentation for the custom error directive and see if it is an inherited setting. I think it is, but am not sure.

You can also override the inherited values by including the custom error handling directive inside the virtualhost section.

You should probably point out that SSL is NOT possible with name-based virtual hosts. There is a bit of a chicken & egg paradox that makes it impossible. The web server needs to look for the host header to find out which set of web content to return. However, in an SSL connection the header information is encrypted. Before the web server can figure out which certificate to pass in the SSL handshake, it needs to know the web host information, which is not viewable until the SSL handshake is complete.

Therefore each SSL site needs it's own IP. For non-SSL sites, name-based works great, but if you are planning on using SSL, then save yourself a headache trying to figure out why it won't work with name based hosts.

That did the trick dave. Seeing your file info was more helpful than you can know. Both my domains are up and cranking now. Now ..if I can get a sumdomain to work......name.domain.com...I'll be in business for sure...
Thanks again
Amos

How to make shure that apache responds with the same page when someone enters www.domain.com or domain.com in their browser?

The best job on this subject I have found. Now direct me to some information on how to ftp to an Apache Server and I will be very happy.

Hi,
'Getting More Out of Apache' is a nice article. I do have some more questions about setting up virtual hosts in apache.

I am trying to redirect requests to different weblogic servers using virtual hosts.
In my setup, I am trying to do something like this in my httpd.conf file .



NameVirtualHost 1.2.3.4

<VirtualHost 1.2.3.4>
ServerName a.domain.com
<IfModule mod_weblogic.c>
WebLogicHost IP1
WebLogicPort Port1
<IfModule>
<Files *.jsp>
SetHandler weblogic-handler
</Files>
</VirtualHost>

<VirtualHost 1.2.3.4>
ServerName b.domain.com
<IfModule mod_weblogic.c>
WebLogicHost IP2
WebLogicPort Port2
<IfModule>
<Files *.jsp>
SetHandler weblogic-handler
</Files>
</VirtualHost>



According to apache documents, I can put <IfModule> tag inside Virtual hosts. However I feel that this tag is not getting recognised.

Please let me know what I am missing?

Thanks in advance.

Mandar

In your Example

<VirtualHost 127.0.0.1>
ServerAdmin webmaster@melonfire-alpha.com
DocumentRoot /www/melonfire-alpha.com
ServerName melonfire-alpha.com
ErrorLog logs/melonfire-alpha.com-error_log
CustomLog logs/melonfire-alpha.com-access_log common
</VirtualHost>

In making the entry for ServerName you did not indicate that the entry needs to be www.melonfire-alpha.com. Unless you proceed your domain name with www. Apache will default to the first entry for all domains you have assigned to your static IP address.










privacy (GDPR)