Skip to content

Commit

Permalink
FIX: an opprotunity to set HTTP-header, used by CherryPy to determine…
Browse files Browse the repository at this point in the history
… origin url of proxy (when HP works behind proxy)

see #rembo10#2616
  • Loading branch information
maxkoryukov committed Apr 20, 2016
1 parent cf0068a commit 99f7613
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
1 change: 1 addition & 0 deletions Headphones.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def main():
'http_host': headphones.CONFIG.HTTP_HOST,
'http_root': headphones.CONFIG.HTTP_ROOT,
'http_proxy': headphones.CONFIG.HTTP_PROXY,
'http_proxy_header_host': headphones.CONFIG.HTTP_PROXY_HEADER_HOST,
'enable_https': headphones.CONFIG.ENABLE_HTTPS,
'https_cert': headphones.CONFIG.HTTPS_CERT,
'https_key': headphones.CONFIG.HTTPS_KEY,
Expand Down
31 changes: 22 additions & 9 deletions headphones/config/definitions/advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,18 +434,31 @@ def reg(_extend_cb):
# =======================================================================================
opts.extend([
BlockExtension('advanced_http_paths', caption=_("Advanced HTTP"), options=_extend_cb(
OptionBool('HTTP_PROXY', 'General', False,
label=_('Behind proxy'),
caption=_('Headphones works behind proxy, and should be careful with generated urls'),
),
OptionString('HTTP_ROOT', 'General', '/',
label=_('HTTP root'),
caption=_('The base part of the URL, without hostname. Just path to home-page of HP.'),
),
OptionSwitch('HTTP_PROXY', 'General', False,
label=_('Behind proxy'),
caption=_('Headphones works behind proxy, HP will modify url appropriately'),
options=_extend_cb(
OptionDropdown('HTTP_PROXY_HEADER_HOST', 'General', '', initype=str,
label=_('HTTP header with external hostname'),
tooltip=_('The name of HTTP header, which will be used by'
' CherryPy.tool.proxy.local to determine the external proxy name'),
caption=_('For example, Apache uses "X-Forwarded-Host"'),
items=(
('', _('Default behaviour')),
('X-Forwarded-Host', _('Apache [X-Forwarded-Host]')),
('X-Host', _('Lighttpd [X-Host]')),
('Host', _('Nginx [Host]')),
)
),
),
),
OptionString('HTTP_ROOT', 'General', '/',
label=_('HTTP root'),
caption=_('The base part of the URL, without hostname. Just path to home-page of HP.'),
),
)),
])


opts.extend([
BlockExtension('advanced_forgotten', caption=_("Strange hidden options"), options=_extend_cb(
MessageExtension(
Expand Down
7 changes: 7 additions & 0 deletions headphones/webstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ def initialize(options):
})
conf['/api'] = {'tools.auth_basic.on': False}

if options['http_proxy'] and options['http_proxy_header_host']:

This comment has been minimized.

Copy link
@maxkoryukov

maxkoryukov Apr 20, 2016

Author Owner

this should resolve rembo10#2616

logger.info("Work behind proxy enabled, and usage of specific HTTP-header"
" is forced: '%s'", options['http_proxy_header_host'])
conf['/'].update({
'tools.proxy.local': options['http_proxy_header_host'],
})

# Prevent time-outs
cherrypy.engine.timeout_monitor.unsubscribe()
cherrypy.tree.mount(WebInterface(), str(options['http_root']), config=conf)
Expand Down

0 comments on commit 99f7613

Please sign in to comment.