Q: How to set Apache to redirect to ServerName port? I just made a fresh Ubuntu install of apache2 and haproxy. Haproxy listens on port 80, apache on 3080, the latter being hidden from outside. 
My problem is that when using a folder name without a trailing slash, e.g. example.com/some/folder apache automatically redirects to the same address with a slash, but also to the incorrect port, example.com:3080/some/folder/!
Apache docs suggest to me that my problem lies with CanonicalName/Port configuration, but any combinations of those do not seem to work. What could I be mis-understanding?
My virtual host:
<VirtualHost *:3080>

    ServerName http://example.com:80
    UseCanonicalName On
    UseCanonicalPhysicalPort On

    DirectoryIndex index.php index.html
    DocumentRoot /var/www/main

    <Directory /var/www/main>
        Options -Indexes
        Options -FollowSymLinks
        AllowOverride All

        <Files ~'^\.'>
            Order allow,deny
            Deny from all
            Satisfy all
        </Files>
    </Directory>
</VirtualHost>


A: Use neither;
UseCanonicalName Off
UseCanonicalPhysicalPort Off

HAProxy doesn't (normally) mess with the sent Host header, so this configuration should have the generated redirects built with the correct Location header.  If this doesn't help, then provide the exact Location header that's being sent in the response?
By the way, your ServerName can be simplified, and probably shouldn't have a port that your vhost isn't listening on:
ServerName example.com

