[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Sheflug] Dynamic IP virtual hosting problem in Apache - the (a) solution



> I have a dynamic IP.  I use dyndns.org along with ddclient on 
> my server (Mandy 8.1) so I always have my domains pointing at 
> my box, even if my IP changes.  I have virtual hosting setup 
> on Apache.  Simple configuration.  I have one dir per domain 
> in home.  Everything works fine!  
> 
> domain1.homelinux.net gets directed to 
> /home/neil/webpages/domain1 and 
> domain2.homelinux.net gets directed to 
> /home/neil/webpages/domain2 etc.
> 
> However, occasionally my connection drops and it comes back 
> after a bit with a new IP.  That's OK, because ddclient 
> updates dyndns and domain1.hom...and domain2.hom... now point 
> to the new IP.  However, and this is the problem, unless I 
> restart Apache, the vhosting stops working, and everything 
> (domain1, domain2, etc.) all point to Docroot.  
> 
> I suspect this problem is because I define vhosts using 
> domain1 and domain2 and when Apache starts it resolves these 
> and then those (now
> old) IPs are fixed.
> 
> If I am right, how can I get Apache to check periodically 
> that domain1.homelinux.net still resolves to the current IP 
> and, if not, then restart or something?

Hi All

Don't know how usual it is to get back to the list when an answer hasn't
come from a query to the list.  Anyhoo, this might be of interest or use
to someone out there, so here goes.

Basically I solved the above problem by using wildcards.

There is some mention in my copy of Apache TDG that Name based virtual
hosting was restricted to distinct IP's to stop any attempts to skirt a
firewall by connecting to an open IP and requesting a website from a
closed IP.  I guess they reconsidered allowing this since my copy was
published.

I believe if you put an actual domain name in the NameVirtualHost and
VirtualHost directives (as I used to!), Apache just resolves the names
and treats them like any other IP. 

so now my vhosts.conf looks like this:-
<><><><>
NameVirtualHost *

<VirtualHost *>
ServerName neils.domain1.net
ServerAlias neils.domain1.net
ServerAdmin admin [at] neils.domain1.net
DocumentRoot /home/neil/webpages/domain1
</VirtualHost>

<VirtualHost *>
ServerName neils.domain2.net
ServerAlias neils.domain2.net
ServerAdmin admin [at] neils.domain2.net
DocumentRoot /home/neil/webpages/domain2
</VirtualHost>

<><><>

As I say, just thought I'd get back to the list with this.

Best wishes

Neil


___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.