Opened 15 years ago
Closed 15 years ago
#9586 closed enhancement (duplicate)
base_url with multiple environments (tracd)
| Reported by: | Owned by: | ||
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | general | Version: | 0.11.6 |
| Severity: | normal | Keywords: | base_url |
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description
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 http://scm.domain.tld/svn/project1/log?rev=1.
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 URLhttp://scm.domain.tld/svn/project1/(rather that Trac'shttp://scm.domain.tld/svn/).
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?
Attachments (0)
Change History (4)
comment:1 by , 15 years ago
| Type: | defect → enhancement |
|---|
comment:2 by , 15 years ago
comment:4 by , 15 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
Indeed, it is a Duplicate of #7573. It didn't come up in my searches.
Thanks for the pointer !



Thinking a bit more about this issue, maybe changing the way
base_urlis interpreted is not a correct approach. One could imagine a scenario where two Trac environments served by the sametracdare proxyed from two completely different URLS (sayhttp://www.site1.tldandhttp://www.site2.tld/code). Having a functionality modifying thebase_urlwould mess everything up in that case (e.g.http://www.site2.tld/code/site2projectisn't desired).Maybe the best approach, then, is to add a new configuration directive
trac_base_urlwhich can be inherited, and do something like the following Python-like pseudocode.if base_url is not None: project_base_url = base_url elif trac_base_url is not None: if multi_environment: project_base_url = trac_base_url + project_name else: project_base_url = trac_base_url else: project_base_url = HTTP_HOST + path