base_url with multiple environments (tracd)
|Reported by:||Owned by:|
Context: I'm using Trac 11.6 from OpenBSD's ports.
tracd manages several environments using the
-e flag. Trac runs behind an Apache proxy which redirects every request to /svn to Trac. For consistency and to simplify proxying rules, Trac serves the content from an identical base path (
--base-path) of /svn.
All the environments inherit from a global trac.ini which contains the following:
[trac] base_url = http://scm.domain.tld/svn/ use_base_url_for_redirect = True
While this may work for single-projects, when serving multiple environments, all of them inherit the same
base_url. They then create URLs respective to the Trac root rather than there own. For example,
project1 will reference
http://scm.domain.tld/svn/log?rev=1, which doesn't exist, rather than
Thus, I think it would be better to consider the
base_url to be the base URL from where Trac is accessible. Depending on the configuration, additional path components may be added to it:
- In single project configurations, the
base_urlcan be used directly as it does reference the root of the project as well as that of Trac.
- In multiple environment configuration, the path to the project should be added to the main
base_urlto actually build the project's base URL
http://scm.domain.tld/svn/project1/(rather that Trac's
This would allow for a more scalable configuration management where the server's
base_url is configured only once and each environment derives its own path from there.
Also, I noticed that when
use_base_url_for_redirect="False", full URLS (e.g. in the RSS) still use 127.0.0.1, where I understood from the documentation that setting
base_url was sufficient to have them replaced, and
use_base_url_for_redirect was only necessary with redirect issues, but not document rewriting. Did I misunderstand? Should
use_base_url_for_redirect be set for document rewriting to work at all?