Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have two servers that are clones of each other save for a few minor configuration changes. I am getting some unexpected behaviour when trying to visit their monitoring.*.com sub domains.

Running ./apache2ctl -S on each server gives the following:

Staging Server

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:443                  is a NameVirtualHost
     default server 010.staging.com (/etc/apache2/sites-enabled/010:2)
     port 443 namevhost 010.staging.com (/etc/apache2/sites-enabled/010:2)
     port 443 namevhost 011.staging.com (/etc/apache2/sites-enabled/011:2)
     port 443 namevhost 013.staging.com (/etc/apache2/sites-enabled/013:2)
*:80                   is a NameVirtualHost
     default server www.production.com (/etc/apache2/sites-enabled/000-default:1)
     port 80 namevhost www.production.com (/etc/apache2/sites-enabled/000-default:1)
     port 80 namevhost monitoring.staging.com (/etc/apache2/sites-enabled/monitoring:1)
Syntax OK

Production Server

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:443                  is a NameVirtualHost
     default server de.production.com (/etc/apache2/sites-enabled/de:2)
     port 443 namevhost de.production.com (/etc/apache2/sites-enabled/de:2)
     port 443 namevhost uk.production.com (/etc/apache2/sites-enabled/uk:2)
     port 443 namevhost us.production.com (/etc/apache2/sites-enabled/us:2)
     port 443 namevhost www.production.com (/etc/apache2/sites-enabled/production:2)
*:80                   is a NameVirtualHost
     default server www.production.com (/etc/apache2/sites-enabled/000-default:1)
     port 80 namevhost www.production.com (/etc/apache2/sites-enabled/000-default:1)
     port 80 namevhost monitoring.production.com (/etc/apache2/sites-enabled/monitoring:1)
Syntax OK

The configuration of 000-default is as follows on both servers

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName www.production.com
    DocumentRoot /home/user/apache/
    RewriteEngine  on
    RewriteLog      /var/log/apache2/log
    RewriteLogLevel 1
    RewriteCond %{REQUEST_URI}/     !^(/server-status).*$
    RewriteRule ^/(.*)$             https://%{SERVER_NAME}/$1 [R=301,L]
</VirtualHost>

The problem I am having is that when I visit http://monitoring.staging.com I am being redirected to http**s**.monitoring.staging.com and being served the app for 010.staging.com the default secure port server.

The production server is behaving as expected and serving my application monitoring tool.

As I said both these servers started out as clones of a master image with only very minor configuration changes - I can describe specific changes if needed.

Can anyone hazard any guesses why I am seeing this behaviour?

Thank you


Updates:

This is the Vhost config for monitoring:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName  monitoring.staging.com
    DocumentRoot /var/www/munin
    <Directory /var/www/munin>
            Options FollowSymLinks
            AllowOverride None
    </Directory>
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
    LogLevel notice
    CustomLog /var/log/apache2/access.log combined
    ErrorLog /var/log/apache2/error.log
    ServerSignature On
</VirtualHost>

And for the app that is actually being served:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName 010.staging.com
    RewriteLog      /var/log/apache2/ssl.log
    RewriteRule ^/$                                         /010/home.htm [R=301,L]
    RewriteRule ^/(?!010/|static/|mgt).*$   /010/home.htm [R=301,L]
    SSLCertificateKeyFile   /etc/apache2/ssl/010/apache.key
    SSLCertificateFile      /etc/apache2/ssl/010/apache.crt
    SSLCACertificateFile    /etc/apache2/ssl/010/apache-ca.crt
</VirtualHost>
</IfModule>
share|improve this question
1  
What kind of redirect are you getting - which response code? Would the application running in that monitoring vhost be redirecting? Otherwise, do you have anything in the config files or in an htaccess file that would have a redirect to https configured? –  Shane Madden Dec 4 '13 at 16:32
    
I am getting a 301 redirect to httpS://monitoring.staging.com when requesting monitoring.staging.com –  Binarytales Dec 4 '13 at 16:38
    
The app that should be delivered by monitoring is just a default Munin installation and does not perform any redirections. I will include the vhost file for monitoring –  Binarytales Dec 4 '13 at 16:40
    
I'm beginning to think that maybe it's staging that is working as expected and production that's squiffy but then the mystery is why production working at all? –  Binarytales Dec 4 '13 at 16:57

1 Answer 1

I solved this by change the 000-default config on staging to the follow:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName staging.com
    DocumentRoot /home/user/apache/
    RewriteEngine  on
    RewriteLog      /var/log/apache2/log
    RewriteLogLevel 1
    RewriteCond %{REQUEST_URI}/     !^(/server-status).*$
    RewriteRule ^/(.*)$             https://%{SERVER_NAME}/$1 [R=301,L]
</VirtualHost>

The change being the ServerName from www.production.com to staging.com

I don't know why this fixed the issue so I am more than happy give a correct answer tick to anyone that can explain the behaviour and what Apache is doing.

share|improve this answer
    
Hmm.. your browser should have never hit the 000-default vhost for a request to monitoring.production.com, but the change to that file fixed it.. so we will need to figure out why that vhost got the request. Did your browser maybe stick a www on the front? –  Shane Madden Dec 4 '13 at 17:23
    
Nope, no extra www from the browser. I get the same results with the HTTPClient.app for OS X. –  Binarytales Dec 5 '13 at 11:04
    
Interesting. Can you fire up a RewriteLog with RewriteLogLevel set high to see what's going on with mod_rewrite? –  Shane Madden Dec 5 '13 at 18:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.