Ticket #6013 (closed enhancement: fixed)
Opened 4 years ago
Last modified 4 months ago
[PATCH] Support X_FORWARDED_PROTO header
| Reported by: | John Hampton <pacopablo@…> | Owned by: | John Hampton <pacopablo@…> |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.12.3 |
| Component: | web frontend | Version: | |
| Severity: | normal | Keywords: | nginx proxy https |
| Cc: | |||
| Release Notes: | |||
| API Changes: | |||
Description
In many proxy configurations, specifically when running tracd behind Nginx, https:// request will get redirected to http://
One solution is to set the base_url in trac.ini. However, this effectively destroys the possibility of having http:// access.
A solution is to simple allow the proxy to set the X_FORWARDED_PROTO header. Attached is a patch to respect the X_FORWARDED_PROTO header.
An example usage in Nginx would be:
location / {
proxy_pass http://dev;
proxy_set_header X-Forwarded-Proto https;
}
Attachments
Change History
Changed 4 years ago by John Hampton <pacopablo@…>
- Attachment x_forwarded_proto.patch added
comment:1 Changed 4 years ago by cmlenz
This is related to #2553.
comment:2 Changed 4 years ago by cmlenz
And #5064.
comment:3 follow-up: ↓ 4 Changed 4 years ago by cmlenz
What I don't get about this: if you're using something like mod_proxy_http, it should be rewriting the Host and Location headers. So if you'd have an outgoing request such as:
301 Moved Temporarily HTTP/1.1 Location: http://localhost:8080/foo
then the proxy should be translating that to the corresponding outside URL:
301 Moved Temporarily HTTP/1.1 Location: https://example.org/foo
(Using ProxyPass and ProxyPassReverse in Apache httpd)
This stuff only works if the absolute URLs generated by Trac match the proxy configuration, which is why we're no longer taking stuff like X_FORWARDED_HOST into account. It seemed like a good idea, but it just throws off the proxy logic.
What am I missing here?
comment:4 in reply to: ↑ 3 ; follow-up: ↓ 5 Changed 4 years ago by John Hampton <pacopablo@…>
Replying to cmlenz:
(Using ProxyPass and ProxyPassReverse in Apache httpd)
This stuff only works if the absolute URLs generated by Trac match the proxy configuration, which is why we're no longer taking stuff like X_FORWARDED_HOST into account. It seemed like a good idea, but it just throws off the proxy logic.
What am I missing here?
The fact that I'm not using apache ;) I hate apache and think it's crap (an opinion shared by many). So I don't use it. Nginx doesn't work that way. It apparently doesn't do any rewriting of responses. So you simply get redirected to http://
I'll setup an apache instance and see how that handles things.
comment:5 in reply to: ↑ 4 Changed 4 years ago by cmlenz
Replying to John Hampton <pacopablo@pacopablo.com>:
Replying to cmlenz:
(Using ProxyPass and ProxyPassReverse in Apache httpd)
This stuff only works if the absolute URLs generated by Trac match the proxy configuration, which is why we're no longer taking stuff like X_FORWARDED_HOST into account. It seemed like a good idea, but it just throws off the proxy logic.
What am I missing here?
The fact that I'm not using apache ;) I hate apache and think it's crap (an opinion shared by many).
Well, that was just an example for what I consider the correct behavior for a reverse HTTP proxy ;)
It looks like Nginx has a similar construct, and it should even be the default IIUC:
http://wiki.codemongers.com/NginxHttpProxyModule#proxy_redirect
comment:6 follow-up: ↓ 7 Changed 4 years ago by cboos
- Milestone changed from 0.11 to 0.11.1
Probably a configuration issue, not for 0.11 anyway.
comment:7 in reply to: ↑ 6 Changed 20 months ago by cboos
- Milestone next-minor-0.12.x deleted
- Resolution set to worksforme
- Status changed from new to closed
Replying to cboos:
Probably a configuration issue, not for 0.11 anyway.
If not a config issue, feel free to reopen.
comment:8 Changed 4 months ago by jomae
- Component changed from general to web frontend
- Milestone set to 0.12.3
- Resolution changed from worksforme to fixed
comment:9 Changed 4 months ago by jomae
- Owner changed from jonas to John Hampton <pacopablo@…>



patch to support X_FORWARDED_PROTO