diff --git a/gui/slick/interfaces/default/config_general.tmpl b/gui/slick/interfaces/default/config_general.tmpl index ede817cf..cba94756 100644 --- a/gui/slick/interfaces/default/config_general.tmpl +++ b/gui/slick/interfaces/default/config_general.tmpl @@ -129,6 +129,14 @@ +
+ + +
+ diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 23157c2e..9c483a1d 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -461,7 +461,7 @@ def initialize(consoleLogging=True): with INIT_LOCK: global ACTUAL_LOG_DIR, LOG_DIR, WEB_PORT, WEB_LOG, ENCRYPTION_VERSION, WEB_ROOT, WEB_USERNAME, WEB_PASSWORD, WEB_HOST, WEB_IPV6, USE_API, API_KEY, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \ - USE_NZBS, USE_TORRENTS, NZB_METHOD, NZB_DIR, DOWNLOAD_PROPERS, PREFER_EPISODE_RELEASES, ALLOW_HIGH_PRIORITY, TORRENT_METHOD, \ + HANDLE_REVERSE_PROXY, USE_NZBS, USE_TORRENTS, NZB_METHOD, NZB_DIR, DOWNLOAD_PROPERS, PREFER_EPISODE_RELEASES, ALLOW_HIGH_PRIORITY, TORRENT_METHOD, \ SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, SAB_HOST, \ NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_HOST, currentSearchScheduler, backlogSearchScheduler, \ TORRENT_USERNAME, TORRENT_PASSWORD, TORRENT_HOST, TORRENT_PATH, TORRENT_RATIO, TORRENT_SEED_TIME, TORRENT_PAUSED, TORRENT_HIGH_BANDWIDTH, TORRENT_LABEL, \ @@ -572,6 +572,8 @@ def initialize(consoleLogging=True): HTTPS_CERT = check_setting_str(CFG, 'General', 'https_cert', 'server.crt') HTTPS_KEY = check_setting_str(CFG, 'General', 'https_key', 'server.key') + HANDLE_REVERSE_PROXY = bool(check_setting_int(CFG, 'General', 'handle_reverse_proxy', 0)) + ACTUAL_CACHE_DIR = check_setting_str(CFG, 'General', 'cache_dir', 'cache') # fix bad configs due to buggy code if ACTUAL_CACHE_DIR == 'None': @@ -1313,6 +1315,7 @@ def save_config(): new_config['General']['enable_https'] = int(ENABLE_HTTPS) new_config['General']['https_cert'] = HTTPS_CERT new_config['General']['https_key'] = HTTPS_KEY + new_config['General']['handle_reverse_proxy'] = int(HANDLE_REVERSE_PROXY) new_config['General']['use_nzbs'] = int(USE_NZBS) new_config['General']['use_torrents'] = int(USE_TORRENTS) new_config['General']['nzb_method'] = NZB_METHOD diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 2b59fe60..d365067c 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -32,7 +32,9 @@ import itertools import operator from Cheetah.Template import Template +import cherrypy import cherrypy.lib +import cherrypy.lib.cptools import sickbeard @@ -79,6 +81,11 @@ except ImportError: from sickbeard import browser +def _handle_reverse_proxy(): + if sickbeard.HANDLE_REVERSE_PROXY: + cherrypy.lib.cptools.proxy() + +cherrypy.tools.handle_reverse_proxy = cherrypy.Tool('before_handler', _handle_reverse_proxy) class PageTemplate(Template): def __init__(self, *args, **KWs): @@ -976,7 +983,7 @@ class ConfigGeneral: def saveGeneral(self, log_dir=None, web_port=None, web_log=None, encryption_version=None, web_ipv6=None, update_shows_on_start=None, update_frequency=None, launch_browser=None, web_username=None, use_api=None, api_key=None, web_password=None, version_notify=None, enable_https=None, https_cert=None, https_key=None, - sort_article=None, auto_update=None, proxy_setting=None, + handle_reverse_proxy=None, sort_article=None, auto_update=None, proxy_setting=None, anon_redirect=None, git_path=None, calendar_unprotected=None, date_preset=None, time_preset=None, indexer_default=None): results = [] @@ -1030,6 +1037,8 @@ class ConfigGeneral: results += [ "Unable to create directory " + os.path.normpath(https_key) + ", https key directory not changed."] + sickbeard.HANDLE_REVERSE_PROXY = config.checkbox_to_value(handle_reverse_proxy) + sickbeard.save_config() if len(results) > 0: diff --git a/sickbeard/webserveInit.py b/sickbeard/webserveInit.py index 7c508e40..661bf6d9 100644 --- a/sickbeard/webserveInit.py +++ b/sickbeard/webserveInit.py @@ -135,6 +135,7 @@ def initWebServer(options={}): 'tools.staticdir.root': options['data_root'], 'tools.encode.on': True, 'tools.encode.encoding': 'utf-8', + 'tools.handle_reverse_proxy.on': True, }, '/images': { 'tools.staticdir.on': True,