tags:

views:

2345

answers:

10

Is this possible? I had troubles with SVN clients not being able to access the repository with the following error message:

Repository moved permanently to 'http://svn.example.com/test/'; please relocate

If I added the '/' to the end of the path I was trying to access, it just strips it off again, and shows the same error message. My configuration file looks like:

<VirtualHost *>
  ServerName svn.example.com
  # Normal VirtualHost stuff here

  <Location /svn>
    # Uncomment this to enable the repository
    DAV svn
    SVNParentPath /some/path/to/repositories

    # Setup mod_authz_svn, etc, etc here
  </Location>
</VirtualHost>

Note: This works. But if I change the Location to just / it stops working again with the error above. Is it possible to use the root directory, or am I missing something here? Firefox displays the repository listing fine when serving the repositories out of the root.

As someone else pointed out, this only seems to be an issue inside named virtual hosts... Anyone have any smart ideas why?

A: 

I ended up using mod_rewrite succesfully to rewrite all access to the root directory into /svn, hence getting access to the repositories from /repository_name. For reference, this is the configuration I ended up with:

# Rewrite / into /svn to avoid errors that seem to occur when using the root
# for repositories.
RewriteEngine On
# Subdirectories that SHOULD be accessed directly, ie. trac
# /svn should be here to avoid redirect loops
RewriteCond %{REQUEST_URI} !^/(trac|svn)/
RewriteRule ^/(.*)$ /svn/$1 [PT]
Matthew Scharley
A: 
This is working for me:

<Location />
    DAV svn
    SVNPath /repository
    AuthType Basic
    AuthName "Repository authentication"
    AuthUserFile /repository/.svn-auth
    AuthzSVNAccessFile /repository/.svn-access
    Satisfy All
    Require valid-user
</Location>

Pointing the browser to http://127.0.0.1 shows me the repository content.

Davide Gualano
It works for browsers fine, but it doesn't work with actual SVN clients; they produce the error in my original post.
Matthew Scharley
I have to disagree: this same configuration is working with the svn command line client (just did a svn ls http://127.0.0.1 getting the correct repo content) and with a GUI client, Versions (http://www.versionsapp.com/) for OSX.
Davide Gualano
Really? Have you tried this inside a VirtualHost (which we need)? That may affect it. But I tested command-line on CentOS, Ubuntu and Tortoise-SVN on windows, and all gave me the same error.
Matthew Scharley
+2  A: 

Continuing from comments to my previous answer, I've tried also with a VirtualHost:

<VirtualHost 127.0.0.1:80>
<Location />
    DAV svn
    SVNPath /repository
    AuthType Basic
    AuthName "Repository authentication"
    AuthUserFile /repository/.svn-auth
    AuthzSVNAccessFile /repository/.svn-access
    Satisfy All
    Require valid-user
</Location>
</VirtualHost>

and it's working, I can browse the repository with firefox and can access it with the svn command line client.

Davide Gualano
Well, I'm stumped then. All I can think of is that we're using named virtual hosts, not IP based ones. I do know that it wouldn't work for us setting up on Ubuntu 8.04 :( I wish it had been that easy. But then again, my way allows us to use trac as a subdirectory too. Thanks for the input though.
Matthew Scharley
Yes, the only difference are the named virtual hosts. I can't try with them because I'm doing this tests on my laptop with a very basic Apache installation. Hope I've been useful :)
Davide Gualano
You could if you added a few names into your hosts file ;) but thanks anyway, I'm stumped as to why it wouldn't work for me, this was essentially my first configuration that you've pasted here, only with named vhosts.
Matthew Scharley
+1  A: 

Ok, I think we have found who to blame: named virtual hosts :)

With this configuration:

<VirtualHost dave.test>
<Location />
    DAV svn
    SVNPath /repository
    AuthType Basic
    AuthName "Repository authentication"
    AuthUserFile /repository/.svn-auth
    AuthzSVNAccessFile /repository/.svn-access
    Satisfy All
    Require valid-user
</Location>
</VirtualHost>

when I run the command svn ls http://dave.test I got this error:

svn: Server sent unexpected return value (405 Method Not Allowed) in response to
PROPFIND request for '/'

So apparently there is an issue when one tries to enable mod_dav_svn in the root directory of a named virtual host...

Davide Gualano
I've had that one show it's ugly head too. I really don't know what causes the issue at all.
Matthew Scharley
A: 

Thanks for this, finally got it working with a VirtualHost due to your comments.

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName svn.example.com
    ServerAlias svn
    DocumentRoot /home/svn.example.com/public_html

    RewriteEngine On

    RewriteCond %{REQUEST_URI} ^/svn$
    RewriteRule .* /svn/ [PT]

    RewriteCond %{REQUEST_URI} !^/svn/
    RewriteRule ^/(.*)$ /svn/$1 [PT]

    <Location /svn>
            DAV svn
            SVNParentPath /home/svn.example.com/public_html
            SVNListParentPath on
    </Location>

    <LocationMatch /svn/.+>
            AuthzSVNAccessFile /home/svn.example.com/support/access.cfg

            AuthType Basic
            AuthName "Subversion"
            AuthUserFile /home/svn.example.com/.htpasswd
            Require valid-user
    </LocationMatch>
</VirtualHost>

As shown I found that you probably want to also add:

RewriteCond %{REQUEST_URI} ^/svn$
RewriteRule .* /svn/ [PT]

In order to catch http://svn.example.com/svn without the ending /.

Nige.

A: 

Naah - scrub that, the ReWriteEngine solution causes loads of problems with Commits and Updates.

+1  A: 

The problem is that you are using the document root also as the repository root (I'm not blaming you, this should just work, but it doesn't).

Try pointing the DocumentRoot and SVNParentPath directives to different physical locations, so the resulting config file should look like this (abbreviated):

<VirtualHost *:80>
    DocumentRoot /home/svn.example.com/docroot

    <Location />
        SVNParentPath /home/svn.example.com/svnroot
        SVNListParentPath on
    </Location>
</VirtualHost>

Also, as @Nigel Jewell says, remove that Rewrite block, for sanity.

azkotoki
This does not work for me. Hitting the root document gives me 403 Forbidden.
Gili
A: 

Excellent - just what I was looking for. Thanks azkotoki!

A: 

Hi, i set:

<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/ForSvn"
ServerName xxx.xxx
ServerAdmin xxx
ErrorLog "/usr/local/apache/logs/xxx-error_log"
TransferLog "/usr/local/apache/logs/xxx-access_log"


ReWriteEngine On
RewriteCond %{REQUEST_URI} ^/svn$
RewriteRule .* /svn/ [PT]

<Location /svn>
       DAV svn
       SVNParentPath /svn/repos
       SVNListParentPath on

       # Limit write permission to list of valid users.
       <LimitExcept GET PROPFIND OPTIONS REPORT>
             AuthType Basic
             AuthName "Subversion"
             AuthUserFile /svn/authfiles/svn-htpasswd
             AuthzSVNAccessFile /svn/authfiles/svn-access.conf
             Require valid-user
       </LimitExcept>
</Location>

<LocationMatch /svn/myProject/>
             AuthType Basic
             AuthName "Subversion (private)"
             AuthUserFile /svn/authfiles/svn-htpasswd
             AuthzSVNAccessFile /svn/authfiles/svn-access.conf
             Require user user1 user2 user3...
</LocationMatch>

and works fine with me. Thank you for this.

A: 

Found this in /etc/apache2/conf.d/subversion.conf (need to map error documents to defaults):

<VirtualHost *>
    ServerName svn.example.com
    ErrorLog    /var/log/apache2/svn.example.com-error_log
    TransferLog /var/log/apache2/svn.example.com-access_log
    #
    # Do not set DocumentRoot. It is not needed here and just causes trouble.
    #
    # Map the error documents back to their defaults.
    # Otherwise mod_dav_svn tries to find a "error" repository.
    #
    ErrorDocument 400 default
    ErrorDocument 401 default
    ErrorDocument 403 default
    ErrorDocument 404 default
    ErrorDocument 405 default
    ErrorDocument 408 default
    ErrorDocument 410 default
    ErrorDocument 411 default
    ErrorDocument 412 default
    ErrorDocument 413 default
    ErrorDocument 414 default
    ErrorDocument 415 default
    ErrorDocument 500 default
    ErrorDocument 501 default
    ErrorDocument 502 default
    ErrorDocument 503 default
    #
    <Location />
...
    </Location>

After I've done this everything started working as expected.

yurique
I still can't get this to work: The URI does not contain the name of a repository. [403, #190001]
Artem Russakovskii