mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Change webserver startup to correctly use xheaders in reverse proxy or load balance set-ups.
This commit is contained in:
parent
413bc38dfd
commit
23df14758f
2 changed files with 10 additions and 14 deletions
|
@ -7,6 +7,7 @@
|
|||
* Update isotope library 2.2.2 to 3.0.1
|
||||
* Add lazyload package 3.0.0 (2e318b1)
|
||||
* Change improve add show search results by comparing search term to an additional unidecoded result set
|
||||
* Change webserver startup to correctly use xheaders in reverse proxy or load balance set-ups
|
||||
|
||||
|
||||
[develop changelog]
|
||||
|
|
|
@ -19,6 +19,7 @@ class WebServer(threading.Thread):
|
|||
self.alive = True
|
||||
self.name = 'TORNADO'
|
||||
self.io_loop = io_loop or IOLoop.current()
|
||||
self.server = None
|
||||
|
||||
self.options = options
|
||||
self.options.setdefault('port', 8081)
|
||||
|
@ -31,8 +32,7 @@ class WebServer(threading.Thread):
|
|||
assert 'data_root' in self.options
|
||||
|
||||
# web root
|
||||
self.options['web_root'] = ('/' + self.options['web_root'].lstrip('/')) if self.options[
|
||||
'web_root'] else ''
|
||||
self.options['web_root'] = ('/' + self.options['web_root'].lstrip('/')) if self.options['web_root'] else ''
|
||||
|
||||
# tornado setup
|
||||
self.enable_https = self.options['enable_https']
|
||||
|
@ -58,10 +58,8 @@ class WebServer(threading.Thread):
|
|||
debug=True,
|
||||
autoreload=False,
|
||||
gzip=True,
|
||||
xheaders=sickbeard.HANDLE_REVERSE_PROXY,
|
||||
cookie_secret=sickbeard.COOKIE_SECRET,
|
||||
login_url='%s/login/' % self.options['web_root']
|
||||
)
|
||||
login_url='%s/login/' % self.options['web_root'])
|
||||
|
||||
# Main Handler
|
||||
self.app.add_handlers('.*$', [
|
||||
|
@ -126,19 +124,16 @@ class WebServer(threading.Thread):
|
|||
])
|
||||
|
||||
def run(self):
|
||||
if self.enable_https:
|
||||
protocol = 'https'
|
||||
self.server = HTTPServer(self.app, ssl_options={'certfile': self.https_cert, 'keyfile': self.https_key})
|
||||
else:
|
||||
protocol = 'http'
|
||||
self.server = HTTPServer(self.app)
|
||||
protocol, ssl_options = (('http', None),
|
||||
('https', {'certfile': self.https_cert, 'keyfile': self.https_key}))[self.enable_https]
|
||||
|
||||
logger.log(u'Starting SickGear on ' + protocol + '://' + str(self.options['host']) + ':' + str(
|
||||
self.options['port']) + '/')
|
||||
|
||||
try:
|
||||
self.server.listen(self.options['port'], self.options['host'])
|
||||
except:
|
||||
self.server = self.app.listen(self.options['port'], self.options['host'], ssl_options=ssl_options,
|
||||
xheaders=sickbeard.HANDLE_REVERSE_PROXY, protocol=protocol)
|
||||
except (StandardError, Exception):
|
||||
etype, evalue, etb = sys.exc_info()
|
||||
logger.log(
|
||||
'Could not start webserver on %s. Excpeption: %s, Error: %s' % (self.options['port'], etype, evalue),
|
||||
|
@ -154,4 +149,4 @@ class WebServer(threading.Thread):
|
|||
|
||||
def shutDown(self):
|
||||
self.alive = False
|
||||
self.io_loop.stop()
|
||||
self.io_loop.stop()
|
||||
|
|
Loading…
Reference in a new issue