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 am having an issue with the redirect that occurs with mod_dir when a trailing slash is missing. Our setup uses a load balancer listening on port 80 with multiple web servers that listen on non-standard ports like 8081.

When mod_dir issues the redirect it is attempting to redirect to domain.com:8081/path/ which of course times out.

I have tried setting UseCanonicalName On and specifying ServerName to include the port like so: domain.com:80 but it doesn't seem to have any effect.

My virtual host is as follows:

Listen 8081
<VirtualHost *:8081>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/domain_static
        UseCanonicalName Off
        ServerName domain.com:80

        <Directory /var/www/domain_static>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride all
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /var/log/apache2/static-error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/static-access.log combined

</VirtualHost>

What can I do to resolve this incorrect redirect behavior?

share|improve this question
    
Your load balancer is where you can account for this behavior - either by manipulating the Host header sent to the port 8081 listener, or rewriting the Location header in the response. What software does it run? –  Shane Madden Jul 24 '12 at 3:12
add comment

1 Answer

Try something like the following:

ServerName domain.com
UseCanonicalName On
UseCanonicalPhysicalPort Off

I think UseCanonicalPhysicalPort Off is the important line.

share|improve this answer
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.