Skip to content
Permalink
Browse files

mgr/dashboard: Allow disabling redirection on standby Dashboards

SSL-enabled dashboard does not play nicely with a frontend HAproxy. To fix that issue there are two configuration options:

1. Disable redirection completely on standby managers.
   $ ceph dashboard set-standby-redirect-enabled "False"

2. Configure the URI of the redirection.
   $ ceph dashboard set-standby-redirect-uri "https://foo.bar.com"

Fixes: https://tracker.ceph.com/issues/24662

Signed-off-by: Volker Theile <vtheile@suse.com>
  • Loading branch information...
votdev committed Jul 16, 2019
1 parent 92eaa76 commit f08cea72c12a6784f50af7072dc6239e69862d8a
Showing with 32 additions and 22 deletions.
  1. +30 −22 src/pybind/mgr/dashboard/module.py
  2. +2 −0 src/pybind/mgr/dashboard/settings.py
@@ -80,7 +80,7 @@ def fixed_init(hc_self, server, sock, makefile=CP_fileobject):
handle_sso_command
from .services.exception import dashboard_exception_handler
from .settings import options_command_list, options_schema_list, \
handle_option_command
handle_option_command, Settings

from .plugins import PLUGIN_MANAGER
from .plugins import feature_toggles # noqa # pylint: disable=unused-import
@@ -510,28 +510,36 @@ def serve(self):
class Root(object):
@cherrypy.expose
def index(self):
active_uri = module.get_active_uri()
if active_uri:
module.log.info("Redirecting to active '%s'", active_uri)
raise cherrypy.HTTPRedirect(active_uri)
if Settings.STANDBY_REDIRECT_ENABLED:
if Settings.STANDBY_REDIRECT_URI:
active_uri = Settings.STANDBY_REDIRECT_URI
else:
active_uri = module.get_active_uri()
if active_uri:
module.log.info("Redirecting to active '%s'", active_uri)
raise cherrypy.HTTPRedirect(active_uri)
else:
template = """
<html>
<!-- Note: this is only displayed when the standby
does not know an active URI to redirect to, otherwise
a simple redirect is returned instead -->
<head>
<title>Ceph</title>
<meta http-equiv="refresh" content="{delay}">
</head>
<body>
No active ceph-mgr instance is currently running
the dashboard. A failover may be in progress.
Retrying in {delay} seconds...
</body>
</html>
"""
return template.format(delay=5)
else:
template = """
<html>
<!-- Note: this is only displayed when the standby
does not know an active URI to redirect to, otherwise
a simple redirect is returned instead -->
<head>
<title>Ceph</title>
<meta http-equiv="refresh" content="{delay}">
</head>
<body>
No active ceph-mgr instance is currently running
the dashboard. A failover may be in progress.
Retrying in {delay} seconds...
</body>
</html>
"""
return template.format(delay=5)
# Return 'Not Found', so proxies can mark this
# node as 'DOWN'.
raise cherrypy.HTTPError(404)

cherrypy.tree.mount(Root(), "{}/".format(self.url_prefix), {})
self.log.info("Starting engine...")
@@ -20,6 +20,8 @@ class Options(object):
"""
ENABLE_BROWSABLE_API = (True, bool)
REST_REQUESTS_TIMEOUT = (45, int)
STANDBY_REDIRECT_ENABLED = (True, bool)
STANDBY_REDIRECT_URI = ('', str)

# API auditing
AUDIT_API_ENABLED = (False, bool)

0 comments on commit f08cea7

Please sign in to comment.
You can’t perform that action at this time.