# HG changeset patch # User Marcin Lulek # Date 2016-09-19 11:48:37 # Node ID da2b72943d1b5fcdab39caadea9cca73473331e3 # Parent b55b9717656ad7e5c50bf3688e393d4c3a4ab236 channelstream: try to use proxy url's unless ws urls are not explictly defined diff --git a/configs/development.ini b/configs/development.ini --- a/configs/development.ini +++ b/configs/development.ini @@ -420,7 +420,9 @@ channelstream.server = 127.0.0.1:9800 ## location of the channelstream server from outside world ## most likely this would be an http server special backend URL, that handles ## websocket connections see nginx example for config -channelstream.ws_url = ws://rhodecode.yourserver.com/_channelstream +# channelstream.ws_url = ws://rhodecode.yourserver.com/_channelstream +## proxy path that can be used by http daemons for exposing channelstream +# channelstream.proxy_path = /_channelstream channelstream.secret = secret channelstream.history.location = %(here)s/channelstream_history diff --git a/configs/production.ini b/configs/production.ini --- a/configs/production.ini +++ b/configs/production.ini @@ -394,7 +394,9 @@ channelstream.server = 127.0.0.1:9800 ## location of the channelstream server from outside world ## most likely this would be an http server special backend URL, that handles ## websocket connections see nginx example for config -channelstream.ws_url = ws://rhodecode.yourserver.com/_channelstream +# channelstream.ws_url = ws://rhodecode.yourserver.com/_channelstream +## proxy path that can be used by http daemons for exposing channelstream +# channelstream.proxy_path = /_channelstream channelstream.secret = secret channelstream.history.location = %(here)s/channelstream_history diff --git a/rhodecode/channelstream/__init__.py b/rhodecode/channelstream/__init__.py --- a/rhodecode/channelstream/__init__.py +++ b/rhodecode/channelstream/__init__.py @@ -27,11 +27,15 @@ from rhodecode.lib.ext_json import json def url_gen(request): + registry = request.registry + longpoll_url = registry.settings.get('channelstream.longpoll_url', '') + ws_url = registry.settings.get('channelstream.ws_url', '') + proxy_url = request.route_url('channelstream_proxy') urls = { - 'connect': request.route_url('channelstream_connect'), - 'subscribe': request.route_url('channelstream_subscribe'), - 'longpoll': request.registry.settings.get('channelstream.longpoll_url', ''), - 'ws': request.registry.settings.get('channelstream.ws_url', '') + 'connect': request.route_path('channelstream_connect'), + 'subscribe': request.route_path('channelstream_subscribe'), + 'longpoll': longpoll_url or proxy_url, + 'ws': ws_url or proxy_url.replace('http', 'ws') } return json.dumps(urls) @@ -78,4 +82,7 @@ def includeme(config): config.add_route( name='channelstream_subscribe', pattern=ADMIN_PREFIX + '/channelstream/subscribe') + config.add_route( + name='channelstream_proxy', + pattern=settings.get('channelstream.proxy_path') or '/_channelstream') config.scan('rhodecode.channelstream')