Fall through vhost for apache

Events happening in the community are now at Drupal community events on www.drupal.org.
j2parker's picture

When a DNS record exists for a domain which has not yet been created or for one which has been configured incorrectly in apache then the visitor is presented with the drupal site installation screen. This is not a desired outcome.

This occurs most notably when someone attempts to access www . example . com when the domain is actually example.com.

A typical aegir installation is performed with the hostmaster domain being installed as aegir.sitename.com. When a vhost configuration file for a domain does not exist apache will serve the first vhost enabled domain listed alphabetically (aegir.sitename.com_80). As a result the domain will be served from the hostmaster code base. As that domain does not exist index.php will perform an internal redirect to install.php, the drupal site installation screen.

One could simply delete the install.php file from the hostmaster code base but then the visitor will receive a Redirect Loop similar to:

Redirect Loop
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

Again not a desired outcome.

The proper way is to create a vhost config file so that it appears first alphabetically.

The following will present the visitor with a 404 Not Found error.

/var/aegir/config/vhost.d/0_fallthrough_80

<VirtualHost :80>

  RewriteEngine On

  RewriteRule .
- [R=404,NC]

  KeepAlive Off

</VirtualHost>

Comments

Good one!

siliconmeadow's picture

I just set this up on my local install, because I was getting annoyed with seeing an install screen that I didn't want. And sometimes confused by it.

One question I have: With the VirtualHost directive above set without an IP or *, I shouldn't worry about the message when restarting apache?:

Syntax error on line 2 of /var/aegir/config/vhost.d/0_fallthrough_80:
The address or port is invalid

Yes, you are correct. For

j2parker's picture

Yes, you are correct. For some unknown reason this drupal system is dropping the *. You need two.

VirtualHost *:80

and

RewriteRule .* - [R=404,NC]

I am very happy with this

j2parker's picture

I am very happy with this rule.

Here's what appeared in my log in just over 1 minutes time from IP 195.159.180.18

Gee, I wonder if he's trying to be helpful.

(2) init rewrite engine with requested uri /phpmyadmin/config/config.inc.php                                                
(3) applying pattern '.' to uri '/phpmyadmin/config/config.inc.php'                                                        
(2) forcing responsecode 404 for /phpmyadmin/config/config.inc.php                                                          
(2) init rewrite engine with requested uri /pma/config/config.inc.php                                                       
(3) applying pattern '.
' to uri '/pma/config/config.inc.php'                                                               
(2) forcing responsecode 404 for /pma/config/config.inc.php                                                                 
(2) init rewrite engine with requested uri /admin/config/config.inc.php                                                     
(3) applying pattern '.' to uri '/admin/config/config.inc.php'                                                             
(2) forcing responsecode 404 for /admin/config/config.inc.php                                                               
(2) init rewrite engine with requested uri /dbadmin/config/config.inc.php                                                   
(3) applying pattern '.
' to uri '/dbadmin/config/config.inc.php'                                                           
(2) forcing responsecode 404 for /dbadmin/config/config.inc.php                                                             
(2) init rewrite engine with requested uri /mysql/config/config.inc.php                                                     
(3) applying pattern '.' to uri '/mysql/config/config.inc.php'                                                             
(2) forcing responsecode 404 for /mysql/config/config.inc.php                                                               
(2) init rewrite engine with requested uri /php-my-admin/config/config.inc.php                                              
(3) applying pattern '.
' to uri '/php-my-admin/config/config.inc.php'                                                      
(2) forcing responsecode 404 for /php-my-admin/config/config.inc.php                                                        
(2) init rewrite engine with requested uri /myadmin/config/config.inc.php                                                   
(3) applying pattern '.' to uri '/myadmin/config/config.inc.php'                                                           
(2) forcing responsecode 404 for /myadmin/config/config.inc.php                                                             
(2) init rewrite engine with requested uri /PHPMYADMIN/config/config.inc.php                                                
(3) applying pattern '.
' to uri '/PHPMYADMIN/config/config.inc.php'                                                        
(2) forcing responsecode 404 for /PHPMYADMIN/config/config.inc.php                                                          
(2) init rewrite engine with requested uri /phpMyAdmin/config/config.inc.php                                                
(3) applying pattern '.' to uri '/phpMyAdmin/config/config.inc.php'                                                        
(2) forcing responsecode 404 for /phpMyAdmin/config/config.inc.php                                                          
(2) init rewrite engine with requested uri /p/m/a/config/config.inc.php                                                     
(3) applying pattern '.
' to uri '/p/m/a/config/config.inc.php'                                                             
(2) forcing responsecode 404 for /p/m/a/config/config.inc.php                                                               
(2) init rewrite engine with requested uri /phpMyAdmin-2/config/config.inc.php                                              
(3) applying pattern '.' to uri '/phpMyAdmin-2/config/config.inc.php'                                                      
(2) forcing responsecode 404 for /phpMyAdmin-2/config/config.inc.php                                                        
(2) init rewrite engine with requested uri /phpMyAdmin-2.2.3/config/config.inc.php                                          
(3) applying pattern '.
' to uri '/phpMyAdmin-2.2.3/config/config.inc.php'                                                  
(2) forcing responsecode 404 for /phpMyAdmin-2.2.3/config/config.inc.php                                                    
(2) init rewrite engine with requested uri /phpMyAdmin-2.2.6/config/config.inc.php                                          
(3) applying pattern '.' to uri '/phpMyAdmin-2.2.6/config/config.inc.php'                                                  
(2) forcing responsecode 404 for /phpMyAdmin-2.2.6/config/config.inc.php                                                    
(2) init rewrite engine with requested uri /phpMyAdmin-2.5.1/config/config.inc.php                                          
(3) applying pattern '.
' to uri '/phpMyAdmin-2.5.1/config/config.inc.php'                                                  
(2) forcing responsecode 404 for /phpMyAdmin-2.5.1/config/config.inc.php                                                    
(2) init rewrite engine with requested uri /phpMyAdmin-2.5.4/config/config.inc.php                                          
(3) applying pattern '.' to uri '/phpMyAdmin-2.5.4/config/config.inc.php'                                                  
(2) forcing responsecode 404 for /phpMyAdmin-2.5.4/config/config.inc.php                                                    
(2) init rewrite engine with requested uri /PHPMYADMIN/config/config.inc.php                                                
(3) applying pattern '.
' to uri '/PHPMYADMIN/config/config.inc.php'                                                        
(2) forcing responsecode 404 for /PHPMYADMIN/config/config.inc.php                                                          
(2) init rewrite engine with requested uri /PMA/config/config.inc.php                                                       
(3) applying pattern '.' to uri '/PMA/config/config.inc.php'                                                               
(2) forcing responsecode 404 for /PMA/config/config.inc.php                                                                 
(2) init rewrite engine with requested uri /PMA2005/config/config.inc.php                                                   
(3) applying pattern '.
' to uri '/PMA2005/config/config.inc.php'                                                           
(2) forcing responsecode 404 for /PMA2005/config/config.inc.php                                                             
(2) init rewrite engine with requested uri /admin/config/config.inc.php                                                     
(3) applying pattern '.' to uri '/admin/config/config.inc.php'                                                             
(2) forcing responsecode 404 for /admin/config/config.inc.php                                                               
(2) init rewrite engine with requested uri /dbadmin/config/config.inc.php                                                   
(3) applying pattern '.
' to uri '/dbadmin/config/config.inc.php'                                                           
(2) forcing responsecode 404 for /dbadmin/config/config.inc.php                                                             
(2) init rewrite engine with requested uri /myadmin/config/config.inc.php                                                   
(3) applying pattern '.' to uri '/myadmin/config/config.inc.php'                                                           
(2) forcing responsecode 404 for /myadmin/config/config.inc.php                                                             
(2) init rewrite engine with requested uri /mysql-admin/config/config.inc.php                                               
(3) applying pattern '.
' to uri '/mysql-admin/config/config.inc.php'                                                       
(2) forcing responsecode 404 for /mysql-admin/config/config.inc.php                                                         
(2) init rewrite engine with requested uri /mysql/config/config.inc.php                                                     
(3) applying pattern '.' to uri '/mysql/config/config.inc.php'                                                             
(2) forcing responsecode 404 for /mysql/config/config.inc.php                                                               
(2) init rewrite engine with requested uri /mysqladminconfig/config.inc.php                                                 
(3) applying pattern '.
' to uri '/mysqladminconfig/config.inc.php'                                                         
(2) forcing responsecode 404 for /mysqladminconfig/config.inc.php                                                           
(2) init rewrite engine with requested uri /p/m/a/config/config.inc.php                                                     
(3) applying pattern '.' to uri '/p/m/a/config/config.inc.php'                                                             
(2) forcing responsecode 404 for /p/m/a/config/config.inc.php                                                               
(2) init rewrite engine with requested uri /pMA/config/config.inc.php                                                       
(3) applying pattern '.
' to uri '/pMA/config/config.inc.php'                                                               
(2) forcing responsecode 404 for /pMA/config/config.inc.php                                                                 
(2) init rewrite engine with requested uri /php-my-admin/config/config.inc.php                                              
(3) applying pattern '.' to uri '/php-my-admin/config/config.inc.php'                                                      
(2) forcing responsecode 404 for /php-my-admin/config/config.inc.php                                                        
(2) init rewrite engine with requested uri /php-myadmin/config/config.inc.php                                               
(3) applying pattern '.
' to uri '/php-myadmin/config/config.inc.php'                                                       
(2) forcing responsecode 404 for /php-myadmin/config/config.inc.php                                                         
(2) init rewrite engine with requested uri /phpMyAdmin-2.2.3/config/config.inc.php                                          
(3) applying pattern '.' to uri '/phpMyAdmin-2.2.3/config/config.inc.php'                                                  
(2) forcing responsecode 404 for /phpMyAdmin-2.2.3/config/config.inc.php                                                    
(2) init rewrite engine with requested uri /phpMyAdmin-2.2.6/config/config.inc.php                                          
(3) applying pattern '.
' to uri '/phpMyAdmin-2.2.6/config/config.inc.php'                                                  
(2) forcing responsecode 404 for /phpMyAdmin-2.2.6/config/config.inc.php                                                    
(2) init rewrite engine with requested uri /phpMyAdmin-2.5.1/config/config.inc.php                                          
(3) applying pattern '.' to uri '/phpMyAdmin-2.5.1/config/config.inc.php'                                                  
(2) forcing responsecode 404 for /phpMyAdmin-2.5.1/config/config.inc.php                                                    
(2) init rewrite engine with requested uri /phpMyAdmin-2.5.4/config/config.inc.php                                          
(3) applying pattern '.
' to uri '/phpMyAdmin-2.5.4/config/config.inc.php'                                                  
(2) forcing responsecode 404 for /phpMyAdmin-2.5.4/config/config.inc.php                                                    
(2) init rewrite engine with requested uri /phpMyAdmin-2.5.5-pl1/config/config.inc.php                                      
(3) applying pattern '.' to uri '/phpMyAdmin-2.5.5-pl1/config/config.inc.php'                                              
(2) forcing responsecode 404 for /phpMyAdmin-2.5.5-pl1/config/config.inc.php                                                
(2) init rewrite engine with requested uri /phpMyAdmin-2.5.5-rc1config/config.inc.php                                       
(3) applying pattern '.
' to uri '/phpMyAdmin-2.5.5-rc1config/config.inc.php'                                               
(2) forcing responsecode 404 for /phpMyAdmin-2.5.5-rc1config/config.inc.php                                                 
(2) init rewrite engine with requested uri /phpMyAdmin-2.5.5-rc2/config/config.inc.php                                      
(3) applying pattern '.' to uri '/phpMyAdmin-2.5.5-rc2/config/config.inc.php'                                              
(2) forcing responsecode 404 for /phpMyAdmin-2.5.5-rc2/config/config.inc.php                                                
(2) init rewrite engine with requested uri /phpMyAdmin-2.5.5/config/config.inc.php                                          
(3) applying pattern '.
' to uri '/phpMyAdmin-2.5.5/config/config.inc.php'                                                  
(2) forcing responsecode 404 for /phpMyAdmin-2.5.5/config/config.inc.php                                                    
(2) init rewrite engine with requested uri /phpMyAdmin-2.5.6-rc1/config/config.inc.php                                      
(3) applying pattern '.' to uri '/phpMyAdmin-2.5.6-rc1/config/config.inc.php'                                              
(2) forcing responsecode 404 for /phpMyAdmin-2.5.6-rc1/config/config.inc.php                                                
(2) init rewrite engine with requested uri /phpMyAdmin-2.5.6-rc2/config/config.inc.php                                      
(3) applying pattern '.
' to uri '/phpMyAdmin-2.5.6-rc2/config/config.inc.php'                                              
(2) forcing responsecode 404 for /phpMyAdmin-2.5.6-rc2/config/config.inc.php                                                
(2) init rewrite engine with requested uri /phpMyAdmin-2.5.6/config/config.inc.php                                          
(3) applying pattern '.' to uri '/phpMyAdmin-2.5.6/config/config.inc.php'                                                  
(2) forcing responsecode 404 for /phpMyAdmin-2.5.6/config/config.inc.php                                                    
(2) init rewrite engine with requested uri /phpMyAdmin-2/config/config.inc.php                                              
(3) applying pattern '.
' to uri '/phpMyAdmin-2/config/config.inc.php'                                                      
(2) forcing responsecode 404 for /phpMyAdmin-2/config/config.inc.php                                                        
(2) init rewrite engine with requested uri /phpMyAdmin/config/config.inc.php                                                
(3) applying pattern '.' to uri '/phpMyAdmin/config/config.inc.php'                                                        
(2) forcing responsecode 404 for /phpMyAdmin/config/config.inc.php                                                          
(2) init rewrite engine with requested uri /phpMyAdmin2/config/config.inc.php                                               
(3) applying pattern '.
' to uri '/phpMyAdmin2/config/config.inc.php'                                                       
(2) forcing responsecode 404 for /phpMyAdmin2/config/config.inc.php                                                         
(2) init rewrite engine with requested uri /phpmanager/config/config.inc.php                                                
(3) applying pattern '.' to uri '/phpmanager/config/config.inc.php'                                                        
(2) forcing responsecode 404 for /phpmanager/config/config.inc.php                                                          
(2) init rewrite engine with requested uri /phpmy-admin/config/config.inc.php                                               
(3) applying pattern '.
' to uri '/phpmy-admin/config/config.inc.php'                                                       
(2) forcing responsecode 404 for /phpmy-admin/config/config.inc.php                                                         
(2) init rewrite engine with requested uri /phpmyadmin/config/config.inc.php                                                
(3) applying pattern '.' to uri '/phpmyadmin/config/config.inc.php'                                                        
(2) forcing responsecode 404 for /phpmyadmin/config/config.inc.php                                                          
(2) init rewrite engine with requested uri /phpmyadmin2/config/config.inc.php                                               
(3) applying pattern '.
' to uri '/phpmyadmin2/config/config.inc.php'                                                       
(2) forcing responsecode 404 for /phpmyadmin2/config/config.inc.php                                                         
(2) init rewrite engine with requested uri /pma/config/config.inc.php                                                       
(3) applying pattern '.' to uri '/pma/config/config.inc.php'                                                               
(2) forcing responsecode 404 for /pma/config/config.inc.php                                                                 
(2) init rewrite engine with requested uri /pma2005/config/config.inc.php                                                   
(3) applying pattern '.
' to uri '/pma2005/config/config.inc.php'                                                           
(2) forcing responsecode 404 for /pma2005/config/config.inc.php
(2) init rewrite engine with requested uri /roundcube/config/config.inc.php
(3) applying pattern '.' to uri '/roundcube/config/config.inc.php'
(2) forcing responsecode 404 for /roundcube/config/config.inc.php
(2) init rewrite engine with requested uri /sl2/data/config/config.inc.php
(3) applying pattern '.
' to uri '/sl2/data/config/config.inc.php'
(2) forcing responsecode 404 for /sl2/data/config/config.inc.php
(2) init rewrite engine with requested uri /sqlmanager/config/config.inc.php
(3) applying pattern '.' to uri '/sqlmanager/config/config.inc.php'
(2) forcing responsecode 404 for /sqlmanager/config/config.inc.php
(2) init rewrite engine with requested uri /sqlweb/config/config.inc.php
(3) applying pattern '.
' to uri '/sqlweb/config/config.inc.php'
(2) forcing responsecode 404 for /sqlweb/config/config.inc.php
(2) init rewrite engine with requested uri /webadmin/config/config.inc.php
(3) applying pattern '.' to uri '/webadmin/config/config.inc.php'
(2) forcing responsecode 404 for /webadmin/config/config.inc.php
(2) init rewrite engine with requested uri /webdb/config/config.inc.php
(3) applying pattern '.
' to uri '/webdb/config/config.inc.php'
(2) forcing responsecode 404 for /webdb/config/config.inc.php
(2) init rewrite engine with requested uri /websql/config/config.inc.php
(3) applying pattern '.*' to uri '/websql/config/config.inc.php'
(2) forcing responsecode 404 for /websql/config/config.inc.php

Well done.

acy76's picture

I really appreciate the concise explanation and fix - thank you.

I inherited an Aegir installation exhibiting this problem and am wondering whether this was due to a faulty installation or other issue? Any ideas as to common errors which cause this? Or any recommended practices to avoid creating this problem in new installations?

Aegir hosting system

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: