$ ceph config set mgr mgr/dashboard/standby_error_status_code 503
+Resolve IP address to hostname before redirect
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The redirect from a standby to the active dashboard is done via the IP
+address. This is done because resolving IP addresses to hostnames can be error
+prone in containerized environments. It is also the reason why the option is
+disabled by default.
+However, in some situations it might be helpful to redirect via the hostname.
+For example if the configured TLS certificate matches only the hostnames. To
+activate the redirection via the hostname run the following command::
+
+ $ ceph config set mgr mgr/dashboard/redirect_resolve_ip_addr True
+
+You can disable it again by::
+
+ $ ceph config set mgr mgr/dashboard/redirect_resolve_ip_addr False
+
HAProxy example configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
import errno
import logging
import os
+import socket
import ssl
import sys
import tempfile
import threading
import time
from typing import TYPE_CHECKING, Optional
+from urllib.parse import urlparse
if TYPE_CHECKING:
if sys.version_info >= (3, 8):
Option(name='standby_behaviour', type='str', default='redirect',
enum_allowed=['redirect', 'error']),
Option(name='standby_error_status_code', type='int', default=500,
- min=400, max=599)
+ min=400, max=599),
+ Option(name='redirect_resolve_ip_addr', type='bool', default=False)
]
MODULE_OPTIONS.extend(options_schema_list())
for options in PLUGIN_MANAGER.hook.get_options() or []:
return None
if active_uri:
+ if module.get_module_option('redirect_resolve_ip_addr'):
+ p_result = urlparse(active_uri)
+ hostname = str(p_result.hostname)
+ fqdn_netloc = p_result.netloc.replace(
+ hostname, socket.getfqdn(hostname))
+ active_uri = p_result._replace(netloc=fqdn_netloc).geturl()
+
module.log.info("Redirecting to active '%s'", active_uri)
raise cherrypy.HTTPRedirect(active_uri)
else: