Edgewall Software
Modify

Opened 10 years ago

Closed 10 years ago

#9586 closed enhancement (duplicate)

base_url with multiple environments (tracd)

Reported by: Olivier Mehani <shtrom-trac@…> Owned by:
Priority: normal Milestone:
Component: general Version: 0.11.6
Severity: normal Keywords: base_url
Cc: Branch:
Release Notes:
API 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_url can 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_url to actually build the project's base URL http://scm.domain.tld/svn/project1/ (rather that Trac's http://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 Olivier Mehani <shtrom-trac@…>, 10 years ago

Type: defectenhancement

comment:2 by Olivier Mehani <shtrom-trac@…>, 10 years ago

Thinking a bit more about this issue, maybe changing the way base_url is interpreted is not a correct approach. One could imagine a scenario where two Trac environments served by the same tracd are proxyed from two completely different URLS (say http://www.site1.tld and http://www.site2.tld/code). Having a functionality modifying the base_url would mess everything up in that case (e.g. http://www.site2.tld/code/site2project isn't desired).

Maybe the best approach, then, is to add a new configuration directive trac_base_url which 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

comment:3 by Remy Blank, 10 years ago

Duplicate of #7573?

comment:4 by Olivier Mehani <shtrom-trac@…>, 10 years ago

Resolution: duplicate
Status: newclosed

Indeed, it is a Duplicate of #7573. It didn't come up in my searches.

Thanks for the pointer !

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.