scenario: follow INSTALL.txt and put the line "Include /var/aegir/conf/vhosts.d" in `/etc/apache2/conf.d/aegir` in oposition to adding the line at the end of apache2.conf or httpd.conf (that is the instruction in other documentation sources and also the way install.sh.txt does).

problem: as apache now read the aegir virtualhosts prior to the ones in sites-enabled, apache will consider the first vhost it reads from `/var/aegir/conf/vhosts.d`the default vhost. The first vhost is the first file in alfabetical order. The default virtualhost is the one that apache will server for the domains that does not match with vhosts domains (ServerName/ServerAlias), and also for the ip (put the ip in the browser).

So the default placeholder became a drupal site, and as the domain does not match, it will bring up the drupal installation screen. It should not be insecure, but is not desirable.

It is still preferable to put a line in `/etc/apache2/conf.d/aegir` instead of apache2.conf/httpd.conf for several reasons, including system upgrades and packaging policies (in debian you can write to other package's configuration files).

So a solution is to define a default virtualhost in `/var/aegir/conf/vhost.d`. As stated above, the default vhost is the first alfabetically. Debian's a2ensite does create a symlink to `sites-available/default` in sites-enabled. The symlink is `000default`. So using 000default is a good option. We can create a completely new file or create a symlink at installation time (or add the instruction to INSTALL.txt/hostmaster):

ln -s /etc/apache2/sites-available/default /var/aegir/config/vhost.d/000default

I speak for Debian, it will apply to Ubuntu but not be the case for other distros that doe not use sites-enabled/sites-available.

Comments

jonhattan’s picture

Title: Make apache go to the default virtualhost for domains it is not aware of » Make apache serve a default virtualhost for domains it is not aware of instead of an aegir's one
Anonymous’s picture

Thanks Jonhattan, I've read this carefully and done various tests and I completely agree with you, and I agree with the solution to symlink to the existing 'default' vhost in Debian based systems: there's no sense in duplicating effort when there's a good chance the OS has already prepared a default vhost for you.

That said, since OSes vary, and in the event there isn't an existing default vhost on the user's system, I think this should be an instruction in the INSTALL.txt and not something we automate.

In the case of install.sh.txt, something like this might suffice:

if [ -f /etc/apache2/sites-available/default ]; then
  # Debian/Ubuntu
  ln -s /etc/apache2/sites-available/default /var/aegir/config/vhost.d/000default
elif [ -f /etc/httpd/conf/httpd.conf ]; then
  # Centos
    if grep -q "Include $CONF_DIR" $HTTPD_CONF
    then
      echo "A default VirtualHost config probably already exists..."
    else
      cat << EOF
       <VirtualHost *:80>
       DocumentRoot /var/www/index.html
     etc...

EOF

obviously a work in progress, talking off the top of my head :)

jonhattan’s picture

don't understand quite well the last part you wrote to apply to install.sh.txt.
On Centos and others, to avoid the problem aegir must be included after vhosts definition. If not, the solution is to create a 000default file in aegir's vhosts directory.

Anonymous’s picture

OK maybe I misunderstood. In any case what I was pointing out is that though this ought to be an instruction in INSTALL.txt requiring manual user input, what about the install.sh script where things are automated.

Feel free to write a patch for either! :)

anarcat’s picture

Status: Active » Closed (duplicate)

See http://drupal.org/node/497522

Basically, I think the platform verification (or the aegir site verification) should create that special vhost. This should be part of the install process, it should be automatically managed by aegir.

Macronomicus’s picture

Thanks Jonhattan, that was exactly what I needed to get my default stuff back.

Cheers!

guypaddock’s picture

On CentOS and others, another possible workaround is to just name the file something like zz020_aegir.conf in the /etc/httpd/conf.d folder, so it gets invoked last.

This is what Plesk does on a few of our hosts for its own Apache config; it generates a file called zz010_psa_httpd.conf.

forestmars’s picture

Putting 000-default in aegir/confi/vhost.d does not work if Aegir is on the same IP as the default domain, eg. foo.net.

That is, if Aegir is installed at aegir.foo.net, then adding the 000-default file to aegir/config/vhost.d will not keep Aegir from responding to foo.com, if foo.com shares an IP with aegir.foo.net.

The problem is worse than that however. If Aegir has a site at bar.foo.net, and Apache has the vhost bar.foo.com, both at the same IP address, Aegir will respond to all requests for bar.foo.com, blowing out the valid vhost.

Is there a way to configure Aegir so that it will only respond to requests from its own domain, and will not respond to other domains that share its IP? Thus far I have not been able to keep Aegir from responding to anything on the same IP, regardless whether Apache has a valid vhost and/or Aegir doesn't.

joakimforsgren’s picture

Issue summary: View changes

Typo