Skip to content

Commit

Permalink
Support X-Forwarded-Host, X-Forwarded-Port and X-Forwarded-Proto, to …
Browse files Browse the repository at this point in the history
…let restarting SickBeard behind a proxy work.

Without this, restart.js will redirect to the internal proto/ip/port, which may be unreachable.

This requires support from the proxy, eg:

proxy_pass http://192.168.0.1:8080;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Port 9999;
proxy_set_header X-Forwarded-Host $host;

To proxy https://host:9999/ to http://192.168.0.1:8080
  • Loading branch information
John Doe committed Mar 1, 2012
1 parent 2020a41 commit 1c26733
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sickbeard/webserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ def __init__(self, *args, **KWs):
self.sbHost = re.match("[^:]+", cherrypy.request.headers['Host'], re.X|re.M|re.S).group(0)
self.projectHomePage = "http://code.google.com/p/sickbeard/"

if "X-Forwarded-Host" in cherrypy.request.headers:
self.sbHost = cherrypy.request.headers['X-Forwarded-Host']
if "X-Forwarded-Port" in cherrypy.request.headers:
self.sbHttpPort = cherrypy.request.headers['X-Forwarded-Port']
self.sbHttpsPort = self.sbHttpPort
if "X-Forwarded-Proto" in cherrypy.request.headers:
self.sbHttpsEnabled = True if cherrypy.request.headers['X-Forwarded-Proto'] == 'https' else False

logPageTitle = 'Logs & Errors'
if len(classes.ErrorViewer.errors):
logPageTitle += ' ('+str(len(classes.ErrorViewer.errors))+')'
Expand Down

0 comments on commit 1c26733

Please sign in to comment.