Commit aa362a51 authored by Daniele Venzano's avatar Daniele Venzano

Make the websocket URL configurable to make it work through reverse proxies

parent a4a95def
......@@ -56,7 +56,7 @@ class BaseAuthenticator:
def pam_authenticate(username, password):
"""Use su for testing credentials. Using directly the PAM library would be more performant, but would also require Zoe to run as root."""
"""Use su for testing credentials. Using directly the PAM library would be easier, but would also require Zoe to run as root."""
try:
child = pexpect.spawn('/bin/su', ['-', username])
......
......@@ -155,5 +155,6 @@ class ServiceLogsWeb(ZoeWebRequestHandler):
template_vars = {
"service": service,
"websocket_base": get_conf().websocket_base + get_conf().reverse_proxy_base
}
self.render('service_logs.jinja2', **template_vars)
......@@ -13,7 +13,7 @@
<p><a href="{{ reverse_url("execution_inspect", service.execution_id) }}">Back to execution details</a></p>
<script type="application/javascript">
var ws = new WebSocket('ws://{{ server_address }}/websocket');
var ws = new WebSocket('{{ websocket_base }}/websocket');
ws.onopen = function (e) {
ws.send(JSON.stringify({
command: "service_logs",
......
......@@ -45,6 +45,10 @@ class WebSocketEndpointWeb(ZoeWSRequestHandler):
if self.current_user is None:
self.close(401, "Unauthorized")
def check_origin(self, origin):
"""Check connection origin."""
return True
@tornado.gen.coroutine
def on_message(self, message):
"""WebSocket message handler."""
......
......@@ -91,6 +91,7 @@ def load_configuration(test_conf=None):
# Proxy options
argparser.add_argument('--proxy-path', help='Proxy base path', default='127.0.0.1')
argparser.add_argument('--reverse-proxy-path', help='Base path in case Zoe is behind a reverse proxy under a path', default='')
argparser.add_argument('--websocket_base', help='Base URL for websocket connections, you need to change it only when running Zoe behind a reverse proxy', default='ws://{{ server_address }}')
# Scheduler
argparser.add_argument('--scheduler-class', help='Scheduler class to use for scheduling ZApps', choices=['ZoeElasticScheduler'], default='ZoeElasticScheduler')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment