Jump to content

Apache2 - dynamic virtual hosts


marcosscriven

Recommended Posts

Hi

I want to be able to add/update/remove virtual hosts dynamically, without restarting Apache 2 every time. My main reason being, I don't want any down time.

I found this tutorial, which is reasonably clear: http://httpd.apache.org/docs/2.0/vhosts/mass.html

What isn't clear to me is the following:

1) If I have virtual hosts www.example1.com and www.example2.com, what happens if I want to do some maintenance work on www.example2.com, such that they just get a page saying 'Maintenance underway blah blah blah', and can't request any other pages?

2) How can I ensure that if the virtual host doesn't exist or has a problem, the default one isn't used

3) How can I, dynamically, choose whether or not a site should be plain text over port 80, or secured over 445?

Just to clarify, what I would like to be able to do is setup any virtual host I wanted, without bouncing the Apache2 process, just by setting up the relevant DNS records, and creating a directory in /var/www/ of the same name, while also being able to determine it's status as SSL or not, and whether it is 'up' or 'down'

I have found a few MODs in Google searches that seem to use MySQL setups, but they seem to be invariably home brew stuff that is not very up to date.

Thanks

Marcos
Link to comment
Share on other sites

[quote]3) How can I, dynamically, choose whether or not a site should be plain text over port 80, or secured over 445?[/quote]

In a .htaccess file, put:
[code]SSLRequireSSL
ErrorDocument 403 https://www.securewebsite.com/
[/code]

Its only a quick hack.

[quote]1) If I have virtual hosts www.example1.com and www.example2.com, what happens if I want to do some maintenance work on www.example2.com, such that they just get a page saying 'Maintenance underway blah blah blah', and can't request any other pages?[/quote]
There are custom error codes you can put in a .htaccess file in the root web folder of www.example2.com

[quote]
2) How can I ensure that if the virtual host doesn't exist or has a problem, the default one isn't used[/quote]
I dont get you there. Do you just want to throw a 404 - Page Not Found? if a virtual host aint exist.
Im sure there is a default page you can use for apache to show if the server is accessed by default, e.g. by IP address or a unconfigured sub-domain name.

-steve
Link to comment
Share on other sites

  • 2 weeks later...
If you comment out the default page at the top of the virtual hosts part of the config (part 3) then this will not be a problem, so long as your using name based hosting.  If your using ip based hosting then it may do a revers lookup on service ip, and show you that page, but it depend how your distributing your ips.

As to the ssl or normal, i do it by setting up the following.  each site has a folder: www.example.com.  With in this they also have to have three other folders docs (for standard on port 80) https (for ssl).  Thus when the user starts by typing https:// they hit the https folder other wise the docs folder.  My third folder is there cgi-bin.

Im assuming your using mod_vhost_alias and something like [i]VirtualDocumentRoot /var/www/html/%0/docs[/i] to achive this?  How many sites are you hosting?  There are a number of other way to do this that, if your not hosting a huge number of sites may be simpler for what you want!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.