SVN COPY 502 Bad Gateway Error

There is a lot of info to be found on the Internet about the “502 Bad Gateway Error” when trying trying to move a directory or files when your repository is hosted on Apache using SSL and WEBDAV. In a nutshell Apache is confused by the COPY command and things you are trying to make a move between HTTP and HTTPS, or in other words, a different host. You can read up on the problem here:

The problem that I ran into was with my HTTP server on the same host. Why do I need an HTTP server you may ask? Well, mainly to redirect requests from to Most of the documentation I was able to find on this suggested simply adding a line to the VirtualHost to update the header, like so:

RequestHeader edit Destination ^https http early

In my case, this just wasn’t working. What did fix it is a bit counter-intuitive – I had to enable the SSLEngine on my HTTP VirtualHost, as well as my HTTPS VirtualHost. My configuration now looks like the following, and I am able to move files again.

SSLCertificateFile /etc/httpd/ssl/self-signed.crt
SSLCertificateKeyFile /etc/httpd/ssl/self-signed.key

<VirtualHost *:80>
        RequestHeader edit Destination ^https http early

        # Turn mod_ssl on even though we are on 80
        SSLEngine on

        # Rewrite HTTP to HTTPS
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

<VirtualHost *:443>

        # Turn mod_ssl on
        SSLEngine on

        <Location "/">
                DAV svn
                SVNPath /var/svn/repository
                AuthzSVNAccessFile /var/svn/repository/conf/authz

                AuthType Basic
                AuthName ""
                AuthUserFile /var/svn/.htauthfile
                Require valid-user

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *