Modify

Opened 7 years ago

Last modified 8 weeks ago

#1489 assigned enhancement

Get base url from environment

Reported by: mtessmer@… Owned by: rjollos
Priority: normal Component: ProjectMenuPlugin
Severity: normal Keywords: base_url reverseproxy
Cc: Trac Release: 0.10

Description

Maybe it is better to get the base url from env:

#base_url, _ = posixpath.split(req.abs_href())
base_url = self.env.base_url

With this the plugin works in my setup.

Attachments (0)

Change History (4)

comment:1 follow-up: Changed 7 years ago by coderanger

This assumes base_url is set, which may not be the case in 0.10. req.abs_href will be based on base_url if present, and if not it will try to auto-detect. What is the problem you get with the current code?

comment:2 in reply to: ↑ 1 Changed 7 years ago by anonymous

Replying to coderanger:

This assumes base_url is set, which may not be the case in 0.10. req.abs_href will be based on base_url if present, and if not it will try to auto-detect. What is the problem you get with the current code?

I set TracEnvParentDir to /vol/trac and TracUriRoot to /projects. The
Apache websever configuration file defines a /projects location to acccess
the Trac project list. If I use your original code and try to switch from a
project A (www.my.server.com/projects/A) to a project B
(www.my.server.com/projects/B), the /projects/ part is missing and the browser is directed
to www.my.server.com/B. Maybe my setup is wrong?

comment:3 Changed 7 years ago by korn

  • Keywords base_url reverseproxy added

Different, but related problem: the apache serving my tracs is behind a reverse proxy that does https and some path remapping. The public URL of a trac instance is https://trac.foo.com/parent/projectA/; however, the backend webserver gets the request as http://trac.intra:2080/parent/projectA/.

The ProjectMenuPlugin will send the browser to http://trac.intra:2080/parent/projectB/ if projectB is selected, instead of https://trac.foo.com/parent/projectB/.

Maybe this is related to http://trac.edgewall.org/ticket/5064; the discussion got a bit convoluted, so I'm not sure. I'm using 0.10.4.

Using mod_proxy_html is a workaround, but I wouldn't call it a solution.

comment:4 Changed 8 weeks ago by rjollos

  • Owner changed from coderanger to rjollos
  • Status changed from new to assigned

Add Comment

Modify Ticket

Action
as assigned .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.