Sunday, January 22, 2012

How to set up Apache Subversion to be accessed via a proxy (With Ubuntu))

I was going to access a subversion repository from my university network proxy for the first time and it was then that i realized that it is not possible with the usual subversion configuration. There are many options can be used in overcoming this  but the following simple solution worked for me very well.

Apache Subversion uses the 'servers' file to keep track of its' server configurations. If we need to use subversion through a proxy server the proxy-host and the port must be first configured in this file as it is not enabled by default. The simple steps to do this is;

1. We have to add the proxy server configuration into the 'servers' file in both locations.
  • /etc/subversion directory in our root directory 
  • .subversion directory in our home directory. 
However it would be sufficient only changing the 'servers' file in  .subversion directory to make this works.
2.However we can't edit the 'servers' file in etc/subversion directory since it demands root permission to edit it. So we have to open file as the root.
Open a terminal window by using ctrl+alt+T keys and enter the following command.

isha@pc:~$ sudo su
[sudo] password for isha: 

This will demand you for the password before providing root privileges.Enter the password and now we have root access in our computer. Go to the directory and open 'servers' file in text editor now.
root@isha-pc:/home/isha# cd /etc/subversion 
root@isha-pc:/etc/subversion# gedit servers
The 'servers' file will be opened now in the text editor. Look for the [global] settings section you will see some lines like this.

[global]
# http-proxy-exceptions = *.exception.com, www.internal-site.org
# http-proxy-host = my.proxy.domain.com
# http-proxy-port = 7000
# http-proxy-username = defaultusername
# http-proxy-password = defaultpassword

Change the 'http-proxy-host' with the address of your proxy server (excluding http:// part) and enter the port number into 'http-proxy-port' line. If you need edit the username and password settings too.

Important: Remove # symbol and all the spaces in front of the line you changed as additional spaces will result errors in the configuration. 

After editing it will look like,

[global]
# http-proxy-exceptions = *.exception.com, www.internal-site.org
http-proxy-host = my.proxy.lk
http-proxy-port = 3100

Save the file and close it.

3.We need to add the same configuration into the 'servers' file in .subversion directory. However it doesn't need root access to edit this file. Therefore open the file as a normal user and add the above details. Save and close.

4. Open a new terminal tab and access subversion repository back.

A useful thread to know additional options will be, svn-over-http-proxy

1 comment:

  1. Thank you so much. This was very helpful to me.

    ReplyDelete