Solution for Subversion 502 Bad Gateway problem when using Forefront as reverse proxy

Just as a slight note to self, but possibly useful for others running Subversion under Apache 2 on Windows (2008 in my case) behind Forefront TMG (nextgen ISA Server). The setup was working very good until I tried committing a move or a copy from my local machine. Typically things started going wrong when doing renames with ReSharper through VisualSVN in Visual Studio.You'll see errors like these:

"Server sent unexpected return value (502 Bad Gateway) in response to COPY"

Some research will quite quickly identify the problem as related to the use of a reverse proxy (Forefront in my case) and problems when using https externally and http internally. Christian Stocker suggests using a perl script to solve this problem, and Tor HÃ¥kon Haugen adds some more SSL config, but there is a much simpler solution available if your setup is much like mine. Just add this line to your httpd.conf:

RequestHeader edit Destination ^https http early

Comments

# SharePoint Experts said:

Just as a slight note to self, but possibly useful for others running Subversion under Apache 2 on Windows

Sunday, December 28, 2008 10:28 AM
# bintkhalid said:

plz tell me how can i solve this problem

Tuesday, January 20, 2009 5:03 AM
# Sean said:

We have a similar setup:

MS ISA Server 2006 <-> Apache 2.2 on Windows Server 2003.

ISA server acts as a reverse proxy converting HTTPS requests to HTTP. It is worth noting the following:

1. mod_headers.so should be enabled

2. The default location of "RequestHeader edit destination ^https: http: early" will probably not work.

"Because early directives are processed before the request path's configuration is traversed, early headers can only be set in a main server or virtual host context. Early directives cannot depend on a request path, so they will fail in contexts such as <Directory> or <Location>."

- publib.boulder.ibm.com/.../mod_headers.html

Copy "RequestHeader edit destination ^https: http: early" and paste it in the lines above <Location /svn> ... </Location>

Wednesday, February 11, 2009 8:05 AM
# Renato Cunha said:

Thanks for the tip. It solved my problem.

It seems to be just related to the external https <-> internal http on a reverse proxy. On my case, I was using lighttpd to proxy subversion stuff to apache via http on the localhost.

Monday, April 27, 2009 8:45 PM
# Jeremy said:

Awesome fix.  thanks!

Wednesday, May 13, 2009 12:51 PM
# Jan said:

Works well thanks you :)

Tuesday, May 26, 2009 4:45 AM
# SSan said:

Doesnt work for me. get an apache error at the time of restart says,.. "RequestHeader too many arguments" Using apache 2.2

Sunday, June 21, 2009 3:43 PM
# Neil said:

@SSan -- The 'edit' directive only came in a version 2.2.4, you may need to upgrade your Apache installation.

Monday, July 27, 2009 6:50 AM
# Jussi said:

I just banged my head into brick wall for about an hour trying to get this work so word of warning for others:

RequestHeader directive DOES NOT WORK when placed inside Location block and Apache gives absolutely no warning about this when started.

I tried to be smart and add this fix inside my (Location /svn/) where I have all other settings too. The lack of mod_headers' debug capabilities didn't help much either.

Sunday, October 25, 2009 7:50 AM
# Jussi said:

And only now i saw the comment n Feb 11th which stated pretty much the same thing I did just now. Anyway the comment about placement should be added to the original post. :)

Sunday, October 25, 2009 7:54 AM

Leave a Comment

(required) 
(required) 
(optional)
(required)