Opened 11 years ago

# Get base url from environment

Reported by: Owned by: mtessmer@… Ryan J Ollos normal ProjectMenuPlugin normal base_url reverseproxy 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.

### comment:1 follow-up:  2 Changed 11 years ago by Noah Kantrowitz

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 11 years ago by anonymous

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 10 years ago by Andras Korn

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 4 years ago by Ryan J Ollos

Owner: changed from Noah Kantrowitz to Ryan J Ollos new → assigned

### Modify Ticket

Change Properties