Svn Over Http Proxy

How to configure a HTTP proxy for svn

Have you seen the FAQ entry What if I'm behind a proxy??

... edit your "servers" configuration file to indicate which proxy to use. The files location depends on your operating system. On Linux or Unix it is located in the directory "~/.subversion". On Windows it is in "%APPDATA%\Subversion". (Try "echo %APPDATA%", note this is a hidden directory.)

For me this involved uncommenting and setting the following lines:

#http-proxy-host=my.proxy
#http-proxy-port=80
#http-proxy-username=[username]
#http-proxy-password=[password]

On command line : nano ~/.subversion/servers

svn over HTTP proxy

In /etc/subversion/servers you are setting http-proxy-host, which has nothing to do with svn:// which connects to a different server usually running on port 3690 started by svnserve command.

If you have access to the server, you can setup svn+ssh:// as explained here.

Update: You could also try using connect-tunnel, which uses your HTTPS proxy server to tunnel connections:

connect-tunnel -P proxy.company.com:8080 -T 10234:svn.example.com:3690

Then you would use

svn checkout svn://localhost:10234/path/to/trunk

SVN unable to connect to host after proxy setup

Proxy has to be set to xxx.xxx.xxx.xxx without specifying any protocol. Remove http:// from the proxy address.

However, http-proxy-host has nothing to do with access via svn:// access scheme. svn:// (svnserve) is a protocol specific to Subversion. http-proxy-host works for HTTP(S) connections only.

So you have two options:

  • Use HTTP(S) URL to the repository. E.g. like this http://svn.freebsd.org/base/.
  • Configure a tunnel as described here and in related threads.

How do I configure the SVN HTTP proxy from the command line?

SVNBook to the rescue!

  1. As you've already mentioned, you can add SVN configuration options to svn command-line client.

    See SVNBook | --config-option command-line reference.

    Sets, for the duration of the command, the value of a runtime
    configuration option. CONFSPEC is a string which specifies the
    configuration option namespace, name and value that you'd like to
    assign, formatted as FILE:SECTION:OPTION=[VALUE]. In this syntax, FILE
    and SECTION are the runtime configuration file (either config or
    servers) and the section thereof, respectively, which contain the
    option whose value you wish to change. OPTION is, of course, the
    option itself, and VALUE the value (if any) you wish to assign to the
    option. For example, to temporarily disable the use of the automatic
    property setting feature, use
    --config-option=config:miscellany:enable-auto-props=no. You can use this option multiple times to change multiple option values
    simultaneously.

    Here is the sample command-line:

    svn checkout ^

    --config-option servers:global:http-proxy-host=<PROXY-HOST> ^

    --config-option servers:global:http-proxy-port=<PORT> <REPO-URL> <LWC-DIR>

  2. Or use --config-dir to point svn command-line client to customized configuration file.

    --config-dir DIR

    Instructs Subversion to read configuration information from the
    specified directory instead of the default location (.subversion in
    the user's home directory).

Is there a way to access Subversion's proxy settings programmatically or from command-line?

Since it doesn't seem to be possible to get the proxy configuration through the svn executable, I resorted to using an embedded Python script. Why Python? Since it has the ConfigParser module, which allows to read/write INI-style files:

    if $(command -v svn &> /dev/null) && $(command -v python &> /dev/null) ; then
python - <<END
import ConfigParser, os
config = ConfigParser.ConfigParser()
config.read(os.path.expanduser('~/.subversion/servers'))
if (config.has_section('global')):
proxy_host = ''
proxy_port = ''
proxy_exceptions = ''
if (config.has_option('global', 'http-proxy-host')):
proxy_host = config.get('global', 'http-proxy-host')
if (config.has_option('global', 'http-proxy-port')):
proxy_port = config.get('global', 'http-proxy-port')
if (config.has_option('global', 'http-proxy-exceptions')):
proxy_exceptions = config.get('global', 'http-proxy-exceptions')
print 'http-proxy-host : ' + proxy_host
print 'http-proxy-port : ' + proxy_port
print 'http-proxy-exceptions: ' + proxy_exceptions
END
fi

This code reads the ~/.subversion/servers file and prints the values. Similar code can be used to change the proxy values.

adding multiple proxy in subversion clients

Yes, you can configure different proxies for different servers. Please, read the documentation: SVNBook | Runtime Configuration Area.

First, you need to configure groups in the servers file. Groups define what proxy server will be used depending on the server URL. Next, you need to add proxy settings to these groups. Here is an example:

[groups]
server1 = svn.example1.com
server2 = svn.anotherdomain.com

[server1]
http-proxy-host = proxy1.domain-name.com
http-proxy-port = 80
http-proxy-username = MyUsername1
http-proxy-password = MyPassword1

[server2]
http-proxy-host = proxy2.domain-name.com
http-proxy-port = 8443
http-proxy-username = MyUsername2
http-proxy-password = MyPassword2

SVNRDUMP via PROXY

Well, I finally got it working.
Added the proxy details in the servers file in the users home directory under .subversion folder (ab001234:/home/myprofile/.subversion).
Wonder why it didn't work when I added it in the proxy settings of the Collabnet Edge console portal.



Related Topics



Leave a reply



Submit