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')