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.

All HTTP requests, such as http://example.com, are getting redirected to https://redmine.example.com, but I only want http://redmine.example.com to be redirected.

I have the following in my 000-default configuration:

<VirtualHost *:80>
        ServerName redmine.example.com
        DocumentRoot /usr/share/redmine/public

        Redirect permanent / https://redmine.example.com
</VirtualHost>

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
        .
        .
        .
</VirtualHost>

Here is my default-ssl configuration:

<VirtualHost *:443>
        ServerName redmine.example.com
        DocumentRoot /usr/share/redmine/public

        SSLEngine on
        SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
        SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

        BrowserMatch "MSIE [2-6]" \
                nokeepalive ssl-unclean-shutdown \
                downgrade-1.0 force-response-1.0
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

        <Directory /usr/share/redmine/public>
                Options FollowSymLinks
                AllowOverride None
                Order allow,deny
                Allow from all
        </Directory>

        LogLevel info
        ErrorLog /var/log/apache2/redmine-error.log
        CustomLog /var/log/apache2/redmine-access.log combined
</VirtualHost>

<VirtualHost *:443>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
        .
        .
        .
</VirtualHost>

Is there anything here that is cause all HTTP requests to be redirected to https://redmine.example.com?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

There's no ServerName in your second <VirtualHost *:80>; without that, no request will ever map to that virtual host.

If you want it to be the default for all requests that aren't to redmine.example.com, then put the redmine vhost below the default vhost in the file.

share|improve this answer
2  
To clarify a bit further: apache will see the first vhost it encounters as the default vhost. So any request for a hostname not explicitely mentioned in a ServerName statement will be served by it. That's why Shane's swap advice is the right thing to do. –  Dennis Kaarsemaker Nov 11 '12 at 21:09
add comment

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.