コンテンツへスキップ
言語を選択日本語

Tunnel for Managed Keycloak

このコンテンツはまだ日本語訳がありません。

The Tunnel connects your Managed Keycloak cluster to a gateway host that you run inside your own network. Keycloak can then reach the private hosts you nominate, for example an LDAP directory or a database used for user federation, without those hosts being exposed to the internet.

The Tunnel carries traffic from the cluster out to your network. To reach the cluster privately from your cloud network instead, see Azure Private Link.

  • One gateway. A Linux host on your network joins the Tunnel. Only that host connects, not your whole network.
  • Only the hosts you list. Keycloak can reach the hosts you add on the cluster’s Private Networking page, and nothing else.
  • An alias for each host. The dashboard gives every host an alias address. Keycloak calls the alias, and your gateway translates it to the host’s real address.
  • An Enterprise plan, or the Private Network add-on on Launch or Business.
  • A cluster in a location that offers the Tunnel. If it does not, the Tunnel tab says that the Tunnel is not available there yet, and nothing else on the cluster changes.
  • A Linux host on your network to act as the gateway, with:
    • root access
    • Tailscale 1.80 or later installed
    • iptables
    • IP forwarding. The setup script turns on IPv4 forwarding on this host.
  • The fully qualified name and the real IPv4 address of each host Keycloak should reach.
  • Permission to change the cluster. With view-only access the page is read-only.
  1. Open the Tunnel tab.

    In the dashboard, open your cluster, choose Private Networking, then the Tunnel tab.

  2. List the reachable hosts.

    Under Reachable hosts, choose Add host and fill in a Host name and a Real address for each host. Use the host’s fully qualified name, such as ldap.corp.example, and its real address in your network. You can list up to 30 hosts. At least one is needed to turn the Tunnel on.

    A host name must be fully qualified, and names such as localhost, *.svc and *.cluster.local are reserved. A real address must be an IPv4 address. Addresses in the 100.64.0.0/10 range are reserved for the Tunnel itself, and loopback, link-local, multicast and benchmarking ranges are refused. The dashboard shows the problem under the row before you save.

  3. Enable the Tunnel and save.

    Turn on Enable Tunnel, then save. Changing the host list restarts your Keycloak instances one at a time, so you choose when:

    • Save and apply now restarts the instances now.
    • Save for maintenance window applies the change in your next maintenance window.

    Each host now shows its Alias, and an Alias block appears. The alias block is the range your gateway advertises, and nothing else.

  4. Run the gateway script.

    Under Connect your gateway, choose Copy script or Download gateway.sh, and run it as root on the Linux host in your network. The script joins the Tunnel and translates each alias to the host’s real address. Running it again is safe.

    The key in the script expires 24 hours after it was issued and is replaced automatically while the Tunnel is pending. If the key has expired, copy the script again.

  5. Check the status.

    The Tunnel shows Pending until your gateway connects, then Connected. The tab also shows how many Keycloak instances are on the Tunnel, for example 2 of 2.

Keycloak does not resolve your host names. Wherever Keycloak calls a private host, use the host’s alias address from the dashboard, not its name or its real address.

For example, if ldap.corp.example shows the alias <alias> in the dashboard, set the connection URL of your LDAP user federation to ldaps://<alias>:636, with the alias address in place of <alias>. Your gateway receives that traffic and passes it to the host’s real address.

Because Keycloak connects by alias address and not by host name, verify the directory’s certificate against that address:

  • Issue the directory’s server certificate with the alias address as an IP subject alternative name, in addition to the host name, so that the address Keycloak connects to matches the certificate.
  • Make sure Keycloak trusts the certificate authority that signed the certificate.
  • Keep certificate validation on. Do not turn off hostname or certificate checks to get past a mismatch.

The same applies to a database or any other private host: use the protocol’s encrypted mode and verify its certificate.

Add, rename or remove hosts on the Tunnel tab and save. After the change is applied, the tab offers Update your gateway after changing hosts. Run that script as root on your connected gateway. It advertises the alias block again and rewrites the translation of each alias. It does not rejoin, so it carries no key.

Status Meaning
Connected Your gateway is connected and the Keycloak instances are on the Tunnel.
Pending The Tunnel is on and waiting for your gateway to connect, or for the instances to join.
Status unavailable The dashboard could not read the status. Try again shortly.

The line Keycloak instances on the Tunnel counts the instances that have joined. After a save it can show fewer than expected while the instances restart one at a time.

The tab says the Tunnel is not available. The cluster’s location does not offer it yet. Choose a location that does, see supported locations, or talk to Skycloak support.

The status stays Pending. Check that you ran the gateway script as root on the gateway host, that the key has not expired. Copy the script again to get a fresh key and run it again.

The script fails on Tailscale. The gateway needs Tailscale 1.80 or later. Upgrade it and run the script again.

The status is Connected, but Keycloak cannot reach a host. Check that your user federation or database setting uses the host’s alias address, not its name. Then check that the gateway can reach the host’s real address and that a firewall on the host allows the gateway.

Keycloak reached the host before a change and not after. After you change the host list, run Update your gateway after changing hosts on the gateway, so each alias points at the right real address.

Save is refused. A message under the row names the problem: a host name that is not fully qualified, a name listed twice, a reserved name, or a real address that is not an IPv4 address or is in a reserved range. Fix the row and save again.

Fewer instances are on the Tunnel than expected. After a save, wait while the instances restart one at a time. If the count does not recover, run the gateway script again and contact support.

The Tunnel turned off. Private networking turns off when the add-on ends. Keycloak can then no longer reach your private hosts, so anything that depends on them, such as LDAP user federation, stops working until the Tunnel is back on. Whether your cluster is reachable over its public hostname depends on the cluster’s inbound networking settings, which the Tunnel does not change.

Turn off Enable Tunnel on the Tunnel tab and save. Keycloak can no longer reach your private hosts, so user federation and other features that depend on them stop working. This does not change how the cluster is reached from outside. You can then remove Tailscale from the gateway host.