[mythtv-commits] Ticket #8317: MythWeb mangling URLs when more than one reverse proxy is used

MythTV mythtv at cvs.mythtv.org
Thu Apr 8 01:14:15 UTC 2010


#8317: MythWeb mangling URLs when more than one reverse proxy is used
-------------------------------+--------------------------------------------
 Reporter:  james@…            |       Owner:  kormoc 
     Type:  defect             |      Status:  new    
 Priority:  trivial            |   Milestone:  unknown
Component:  Plugin - MythWeb   |     Version:  head   
 Severity:  low                |     Mlocked:  0      
-------------------------------+--------------------------------------------
 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($_SERVER['HTTP_X_FORWARDED_HOST']) ?
 $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_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($_SERVER['HTTP_X_FORWARDED_HOST']))
     list($_SERVER['HTTP_X_FORWARDED_HOST']) = explode(',',
 $_SERVER['HTTP_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.

-- 
Ticket URL: <http://svn.mythtv.org/trac/ticket/8317>
MythTV <http://www.mythtv.org/>
MythTV


More information about the mythtv-commits mailing list