mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-03 18:03:37 +00:00
Merge pull request #360 from nightexcessive/feature/reverse-proxy
Add proper handling for reverse proxies
This commit is contained in:
commit
7ebecc0f24
4 changed files with 23 additions and 2 deletions
|
@ -129,6 +129,14 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="field-pair">
|
||||||
|
<input type="checkbox" name="handle_reverse_proxy" id="handle_reverse_proxy" #if $sickbeard.HANDLE_REVERSE_PROXY then "checked=\"checked\"" else ""#/>
|
||||||
|
<label class="clearfix" for="handle_reverse_proxy">
|
||||||
|
<span class="component-title">Handle reverse proxies</span>
|
||||||
|
<span class="component-desc">Should Sick Beard accept reverse proxy headers? (X-Forwarded-Host, X-Forwarded-For, X-Forwarded-Proto)</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<input type="submit" class="btn config_submitter" value="Save Changes" />
|
<input type="submit" class="btn config_submitter" value="Save Changes" />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div><!-- /component-group1 //-->
|
</div><!-- /component-group1 //-->
|
||||||
|
|
|
@ -462,7 +462,7 @@ def initialize(consoleLogging=True):
|
||||||
with INIT_LOCK:
|
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, \
|
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, \
|
SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, SAB_HOST, \
|
||||||
NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_HOST, currentSearchScheduler, backlogSearchScheduler, \
|
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, \
|
TORRENT_USERNAME, TORRENT_PASSWORD, TORRENT_HOST, TORRENT_PATH, TORRENT_RATIO, TORRENT_SEED_TIME, TORRENT_PAUSED, TORRENT_HIGH_BANDWIDTH, TORRENT_LABEL, \
|
||||||
|
@ -573,6 +573,8 @@ def initialize(consoleLogging=True):
|
||||||
HTTPS_CERT = check_setting_str(CFG, 'General', 'https_cert', 'server.crt')
|
HTTPS_CERT = check_setting_str(CFG, 'General', 'https_cert', 'server.crt')
|
||||||
HTTPS_KEY = check_setting_str(CFG, 'General', 'https_key', 'server.key')
|
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')
|
ACTUAL_CACHE_DIR = check_setting_str(CFG, 'General', 'cache_dir', 'cache')
|
||||||
# fix bad configs due to buggy code
|
# fix bad configs due to buggy code
|
||||||
if ACTUAL_CACHE_DIR == 'None':
|
if ACTUAL_CACHE_DIR == 'None':
|
||||||
|
@ -1311,6 +1313,7 @@ def save_config():
|
||||||
new_config['General']['enable_https'] = int(ENABLE_HTTPS)
|
new_config['General']['enable_https'] = int(ENABLE_HTTPS)
|
||||||
new_config['General']['https_cert'] = HTTPS_CERT
|
new_config['General']['https_cert'] = HTTPS_CERT
|
||||||
new_config['General']['https_key'] = HTTPS_KEY
|
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_nzbs'] = int(USE_NZBS)
|
||||||
new_config['General']['use_torrents'] = int(USE_TORRENTS)
|
new_config['General']['use_torrents'] = int(USE_TORRENTS)
|
||||||
new_config['General']['nzb_method'] = NZB_METHOD
|
new_config['General']['nzb_method'] = NZB_METHOD
|
||||||
|
|
|
@ -32,7 +32,9 @@ import itertools
|
||||||
import operator
|
import operator
|
||||||
|
|
||||||
from Cheetah.Template import Template
|
from Cheetah.Template import Template
|
||||||
|
import cherrypy
|
||||||
import cherrypy.lib
|
import cherrypy.lib
|
||||||
|
import cherrypy.lib.cptools
|
||||||
|
|
||||||
import sickbeard
|
import sickbeard
|
||||||
|
|
||||||
|
@ -79,6 +81,11 @@ except ImportError:
|
||||||
|
|
||||||
from sickbeard import browser
|
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):
|
class PageTemplate(Template):
|
||||||
def __init__(self, *args, **KWs):
|
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,
|
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,
|
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,
|
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):
|
anon_redirect=None, git_path=None, calendar_unprotected=None, date_preset=None, time_preset=None, indexer_default=None):
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
|
@ -1030,6 +1037,8 @@ class ConfigGeneral:
|
||||||
results += [
|
results += [
|
||||||
"Unable to create directory " + os.path.normpath(https_key) + ", https key directory not changed."]
|
"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()
|
sickbeard.save_config()
|
||||||
|
|
||||||
if len(results) > 0:
|
if len(results) > 0:
|
||||||
|
|
|
@ -135,6 +135,7 @@ def initWebServer(options={}):
|
||||||
'tools.staticdir.root': options['data_root'],
|
'tools.staticdir.root': options['data_root'],
|
||||||
'tools.encode.on': True,
|
'tools.encode.on': True,
|
||||||
'tools.encode.encoding': 'utf-8',
|
'tools.encode.encoding': 'utf-8',
|
||||||
|
'tools.handle_reverse_proxy.on': True,
|
||||||
},
|
},
|
||||||
'/images': {
|
'/images': {
|
||||||
'tools.staticdir.on': True,
|
'tools.staticdir.on': True,
|
||||||
|
|
Loading…
Reference in a new issue