Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable mod_dav_svn in the root directory of a named virtual host?

Tags:

svn

apache

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?

like image 741
Matthew Scharley Avatar asked Nov 05 '08 09:11

Matthew Scharley


4 Answers

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.

like image 184
azkotoki Avatar answered Oct 19 '22 09:10

azkotoki


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.

like image 34
Davide Gualano Avatar answered Oct 19 '22 07:10

Davide Gualano


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.

like image 2
yurique Avatar answered Oct 19 '22 08:10

yurique


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]
like image 1
Matthew Scharley Avatar answered Oct 19 '22 07:10

Matthew Scharley