Opened 14 years ago

Closed 14 years ago

#8317 closed defect (fixed)

MythWeb mangling URLs when more than one reverse proxy is used

Reported by: james@… Owned by: Rob Smith
Priority: trivial Milestone: unknown
Component: Plugin - MythWeb Version: head
Severity: low Keywords:
Cc: Ticket locked: no

Description

In 0.22, MythWeb was modified to write literal rather than relative URLs into the rendered pages. To handle conditions where the MythWeb instance is behind a reverse proxy, the following code is used to fill in the externally visible hostname based on the value passed in HTTP_X_FORWARDED_HOST:

define('http_host', isset($_SERVERHTTP_X_FORWARDED_HOST?) ? $_SERVERHTTP_X_FORWARDED_HOST? : $_SERVERHTTP_HOST?);

In the case where the MythWeb instance is behind more than reverse proxy, however, this method fails. The HTTP_X_FORWARDED_HOST will contain a comma-delimited list of all of the reverse proxies (i.e. "proxy1.example.com, proxy2.example.com, proxy3.example.com"). This results in rather useless URLs in the rendered pages. This problem is easy to fix, however, as the first hostname is always the most external. By adding the following code right before that, this can be mitigated:

if(isset($_SERVERHTTP_X_FORWARDED_HOST?))

list($_SERVERHTTP_X_FORWARDED_HOST?) = explode(',', $_SERVERHTTP_X_FORWARDED_HOST?);

This simply throws away everything in HTTP_X_FORWARDED_HOST that appears after the first comma.

I will admit that I'm probably the only person in the world that actually has this issue, due to the ridiculous nature of my network. And no, I don't have 3 proxies, only 2.

Change History (2)

comment:1 Changed 14 years ago by anonymous

Er... I forgot about WikiFormatting when making my post.

comment:2 Changed 14 years ago by Rob Smith

Resolution: fixed
Status: newclosed

(In [24933]) Fixes #8317, this chomps down to a single forwarded hostname for reverse proxies

Note: See TracTickets for help on using tickets.