def config_default_frontend(ssl_bind_string):
    cfg = OrderedDict()
    monitor_uri_configured = False
    frontend = [("bind :80 %s" % EXTRA_BIND_SETTINGS.get('80', "")).strip(),
                "reqadd X-Forwarded-Proto:\ http", "maxconn %s" % MAXCONN]

    if MONITOR_URI and MONITOR_PORT == '80':
        frontend.append("monitor-uri %s" % MONITOR_URI)
        monitor_uri_configured = True

    if "80" in EXTRA_FRONTEND_SETTINGS:
        frontend.extend(EXTRA_FRONTEND_SETTINGS["80"])

    frontend.append("default_backend default_service")
    cfg["frontend default_port_80"] = frontend

    if ssl_bind_string:
        ssl_frontend = [("bind :443 %s %s" % (ssl_bind_string, EXTRA_BIND_SETTINGS.get('443', ""))).strip(),
                        "reqadd X-Forwarded-Proto:\ https", "maxconn %s" % MAXCONN]

        if MONITOR_URI and (MONITOR_PORT == '443'):
            ssl_frontend.append("monitor-uri %s" % MONITOR_URI)
            monitor_uri_configured = True

        if "443" in EXTRA_FRONTEND_SETTINGS:
            ssl_frontend.extend(EXTRA_FRONTEND_SETTINGS["443"])

        ssl_frontend.append("default_backend default_service")
        cfg["frontend default_port_443"] = ssl_frontend

    return cfg, monitor_uri_configured
示例#2
0
def config_default_frontend_by_port(port, ssl_bind_string):
    monitor_uri_configured = False
    if ssl_bind_string:
        frontend = [
            ("bind :%s %s %s" % (port, ssl_bind_string,
                                 EXTRA_BIND_SETTINGS.get(port, ""))).strip()
        ]
        # add x-forwarded-porto header if not skipped
        if not SKIP_FORWARDED_PROTO:
            frontend.append("reqadd X-Forwarded-Proto:\ https")
    else:
        frontend = [("bind :%s %s" %
                     (port, EXTRA_BIND_SETTINGS.get(port, ""))).strip()]
        if not SKIP_FORWARDED_PROTO:
            frontend.append("reqadd X-Forwarded-Proto:\ http")

    frontend.append("maxconn %s" % MAXCONN)

    if MONITOR_URI and MONITOR_PORT == port:
        frontend.append("monitor-uri %s" % MONITOR_URI)
        monitor_uri_configured = True

    if port in EXTRA_FRONTEND_SETTINGS:
        frontend.extend(EXTRA_FRONTEND_SETTINGS[port])

    if "True" in FORCE_DEFAULT_BACKEND:
        frontend.append("default_backend default_service")
    return frontend, monitor_uri_configured
示例#3
0
def config_default_frontend(ssl_bind_string):
    cfg = OrderedDict()
    monitor_uri_configured = False
    frontend = [
        ("bind %s:80 %s" %
         (PRE_BIND_SETTINGS, EXTRA_BIND_SETTINGS.get('80', ""))).strip()
    ]
    frontend.append("bind :::80")

    # add x-forwarded-porto header if not skipped
    if not SKIP_FORWARDED_PROTO:
        frontend.append("reqadd X-Forwarded-Proto:\ http")

    frontend.append("maxconn %s" % MAXCONN)

    if MONITOR_URI and MONITOR_PORT == '80':
        frontend.append("monitor-uri %s" % MONITOR_URI)
        monitor_uri_configured = True

    if "80" in EXTRA_FRONTEND_SETTINGS:
        frontend.extend(EXTRA_FRONTEND_SETTINGS["80"])

    if "True" in FORCE_DEFAULT_BACKEND:
        frontend.append("default_backend default_service")

    cfg["frontend default_port_80"] = frontend

    if ssl_bind_string:
        ssl_frontend = [("bind %s:443 %s %s" %
                         (PRE_BIND_SETTINGS, ssl_bind_string,
                          EXTRA_BIND_SETTINGS.get('443', ""))).strip()]

        # add x-forwarded-porto header if not skipped
        if not SKIP_FORWARDED_PROTO:
            ssl_frontend.append("reqadd X-Forwarded-Proto:\ https")

        ssl_frontend.append("maxconn %s" % MAXCONN)

        if MONITOR_URI and (MONITOR_PORT == '443'):
            ssl_frontend.append("monitor-uri %s" % MONITOR_URI)
            monitor_uri_configured = True

        if "443" in EXTRA_FRONTEND_SETTINGS:
            ssl_frontend.extend(EXTRA_FRONTEND_SETTINGS["443"])

        if "True" in FORCE_DEFAULT_BACKEND:
            ssl_frontend.append("default_backend default_service")

        cfg["frontend default_port_443"] = ssl_frontend

    return cfg, monitor_uri_configured
def config_default_frontend(ssl_bind_string):
    cfg = OrderedDict()
    monitor_uri_configured = False
    frontend = [("bind :80 %s" % EXTRA_BIND_SETTINGS.get('80', "")).strip()]

    # add x-forwarded-porto header if not skipped
    if not SKIP_FORWARDED_PROTO:
        frontend.append("reqadd X-Forwarded-Proto:\ http")

    frontend.append("maxconn %s" % MAXCONN)

    if MONITOR_URI and MONITOR_PORT == '80':
        frontend.append("monitor-uri %s" % MONITOR_URI)
        monitor_uri_configured = True

    if "80" in EXTRA_FRONTEND_SETTINGS:
        frontend.extend(EXTRA_FRONTEND_SETTINGS["80"])

    if "True" in FORCE_DEFAULT_BACKEND:
        frontend.append("default_backend default_service")

    cfg["frontend default_port_80"] = frontend

    if ssl_bind_string:
        ssl_frontend = [("bind :443 %s %s" % (ssl_bind_string, EXTRA_BIND_SETTINGS.get('443', ""))).strip()]

        # add x-forwarded-porto header if not skipped
        if not SKIP_FORWARDED_PROTO:
            ssl_frontend.append("reqadd X-Forwarded-Proto:\ https")

        ssl_frontend.append("maxconn %s" % MAXCONN)

        if MONITOR_URI and (MONITOR_PORT == '443'):
            ssl_frontend.append("monitor-uri %s" % MONITOR_URI)
            monitor_uri_configured = True

        if "443" in EXTRA_FRONTEND_SETTINGS:
            ssl_frontend.extend(EXTRA_FRONTEND_SETTINGS["443"])

        if "True" in FORCE_DEFAULT_BACKEND:
            ssl_frontend.append("default_backend default_service")

        cfg["frontend default_port_443"] = ssl_frontend

    return cfg, monitor_uri_configured
def config_default_frontend(ssl_bind_string):
    cfg = OrderedDict()
    monitor_uri_configured = False
    frontend = [("bind :80 %s" % EXTRA_BIND_SETTINGS.get('80', "")).strip()]
    if ssl_bind_string:
        frontend.append(
            ("bind :443 %s %s" % (ssl_bind_string, EXTRA_BIND_SETTINGS.get('443', ""))).strip())
        frontend.append("reqadd X-Forwarded-Proto:\ https")

    if MONITOR_URI and (MONITOR_PORT == '80' or MONITOR_PORT == '443'):
        frontend.append("monitor-uri %s" % MONITOR_URI)
        monitor_uri_configured = True

    frontend.append("maxconn %s" % MAXCONN)
    frontend.append("default_backend default_service")
    cfg["frontend default_frontend"] = frontend

    return cfg, monitor_uri_configured
def config_default_frontend(ssl_bind_string):
    cfg = OrderedDict()
    monitor_uri_configured = False
    frontend = [("bind :80 %s" % EXTRA_BIND_SETTINGS.get('80', "")).strip()]
    if ssl_bind_string:
        frontend.append(
            ("bind :443 %s %s" %
             (ssl_bind_string, EXTRA_BIND_SETTINGS.get('443', ""))).strip())
        frontend.append("reqadd X-Forwarded-Proto:\ https")

    if MONITOR_URI and (MONITOR_PORT == '80' or MONITOR_PORT == '443'):
        frontend.append("monitor-uri %s" % MONITOR_URI)
        monitor_uri_configured = True

    frontend.append("maxconn %s" % MAXCONN)
    frontend.append("default_backend default_service")
    cfg["frontend default_frontend"] = frontend

    return cfg, monitor_uri_configured
def get_bind_string(port, ssl_bind_string, vhosts):
    ssl = False
    for v in vhosts:
        if v["port"] == port:
            scheme = v["scheme"].lower()
            if scheme in ["https", "wss"] and ssl_bind_string:
                ssl = True
                break
    bind = " ".join([port, EXTRA_BIND_SETTINGS.get(port, "")])
    if ssl:
        bind = " ".join([bind.strip(), ssl_bind_string])
    return bind.strip(), ssl
示例#8
0
def get_bind_string(port, ssl_bind_string, vhosts):
    ssl = False
    for v in vhosts:
        if v["port"] == port:
            scheme = v["scheme"].lower()
            if scheme in ["https", "wss"] and ssl_bind_string:
                ssl = True
                break
    bind = " ".join([port, EXTRA_BIND_SETTINGS.get(port, "")])
    if ssl:
        bind = " ".join([bind.strip(), ssl_bind_string])
    return bind.strip(), ssl
def config_default_frontend_by_port(port, ssl_bind_string):
    monitor_uri_configured = False
    if ssl_bind_string:
        frontend = [("bind :%s %s %s" % (port, ssl_bind_string, EXTRA_BIND_SETTINGS.get(port, ""))).strip()]
        # add x-forwarded-porto header if not skipped
        if not SKIP_FORWARDED_PROTO:
            frontend.append("reqadd X-Forwarded-Proto:\ https")
    else:
        frontend = [("bind :%s %s" % (port, EXTRA_BIND_SETTINGS.get(port, ""))).strip()]
        if not SKIP_FORWARDED_PROTO:
            frontend.append("reqadd X-Forwarded-Proto:\ http")

    frontend.append("maxconn %s" % MAXCONN)

    if MONITOR_URI and MONITOR_PORT == port:
        frontend.append("monitor-uri %s" % MONITOR_URI)
        monitor_uri_configured = True

    if port in EXTRA_FRONTEND_SETTINGS:
        frontend.extend(EXTRA_FRONTEND_SETTINGS[port])

    if "True" in FORCE_DEFAULT_BACKEND:
        frontend.append("default_backend default_service")
    return frontend, monitor_uri_configured
示例#10
0
def config_default_frontend(ssl_bind_string):
    cfg = OrderedDict()
    monitor_uri_configured = False
    frontend = [("bind :80 %s" % EXTRA_BIND_SETTINGS.get('80', "")).strip(),
                "reqadd X-Forwarded-Proto:\ http",
                "maxconn %s" % MAXCONN]

    if MONITOR_URI and MONITOR_PORT == '80':
        frontend.append("monitor-uri %s" % MONITOR_URI)
        monitor_uri_configured = True

    if "80" in EXTRA_FRONTEND_SETTINGS:
        frontend.extend(EXTRA_FRONTEND_SETTINGS["80"])

    frontend.append("default_backend default_service")
    cfg["frontend default_port_80"] = frontend

    if ssl_bind_string:
        ssl_frontend = [
            ("bind :443 %s %s" %
             (ssl_bind_string, EXTRA_BIND_SETTINGS.get('443', ""))).strip(),
            "reqadd X-Forwarded-Proto:\ https",
            "maxconn %s" % MAXCONN
        ]

        if MONITOR_URI and (MONITOR_PORT == '443'):
            ssl_frontend.append("monitor-uri %s" % MONITOR_URI)
            monitor_uri_configured = True

        if "443" in EXTRA_FRONTEND_SETTINGS:
            ssl_frontend.extend(EXTRA_FRONTEND_SETTINGS["443"])

        ssl_frontend.append("default_backend default_service")
        cfg["frontend default_port_443"] = ssl_frontend

    return cfg, monitor_uri_configured