Skip to content

Commit 03f788a

Browse files
committed
enhance LB instructions
1 parent 849508e commit 03f788a

File tree

1 file changed

+76
-43
lines changed

1 file changed

+76
-43
lines changed

src/content/docs/cloudflare-one/connections/connect-networks/routing-to-tunnel/public-load-balancers.mdx

Lines changed: 76 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,52 @@ sidebar:
55
order: 3
66
---
77

8-
import { Render, TabItem, Tabs } from "~/components";
8+
import { Render, DashButton } from "~/components";
99

10-
A [public load balancer](/load-balancing/load-balancers/) allows you to distribute traffic across the servers that are running your [published applications](/cloudflare-one/connections/connect-networks/routing-to-tunnel/). When you add a [published application route]() to your Cloudflare Tunnel, Cloudflare generates a subdomain of `cfargotunnel.com` with the UUID of the created tunnel. `<UUID>.cfargotunnel.com` as if it were a public load balancer endpoint.
10+
A [public load balancer](/load-balancing/load-balancers/) allows you to distribute traffic across the servers that are running your [published applications](/cloudflare-one/connections/connect-networks/routing-to-tunnel/).
1111

12-
Unlike publicly routable IP addresses, the subdomain will only proxy traffic for a load balancer pool in the same Cloudflare account. If someone discovers your subdomain UUID, they will not be able to create a DNS record in another account or system to proxy traffic to the address.
12+
When you add a [published application route](/cloudflare-one/connections/connect-networks/get-started/create-remote-tunnel/#2a-publish-an-application) to your Cloudflare Tunnel, Cloudflare generates a subdomain of `cfargotunnel.com` with the UUID of the created tunnel. You can add the application to a load balancer pool by using `<UUID>.cfargotunnel.com` as the [endpoint address](/load-balancing/understand-basics/load-balancing-components/#endpoints) and specifying the application hostname (`app.example.com`) in the [host header](/load-balancing/additional-options/override-http-host-headers/). Load Balancer does not support directly adding `app.example.com` as an endpoint if the service is behind Cloudflare Tunnel.
1313

14-
The DNS record (`UUID.cfargotunnel.com`) for each Cloudflare Tunnel is the load balancer endpoint address. Host header is required for tunnel endpoints.
14+
## Create a public load balancer
15+
16+
### Prerequisites
17+
18+
- A Cloudflare Tunnel with a [published application route](/cloudflare-one/connections/connect-networks/get-started/create-remote-tunnel/#2a-publish-an-application)
19+
- A `CNAME` DNS record that points the application hostname (`app.example.com`) to `<UUID>.cfargotunnel.com`. This DNS record is automatically created for routes configured through the dashboard. Routes configured via the API or CLI require [manually creating the record](/cloudflare-one/connections/connect-networks/routing-to-tunnel/dns/).
20+
21+
### Create a load balancer
22+
23+
To create a load balancer for Cloudflare Tunnel published applications:
24+
25+
1. In the Cloudflare dashboard, go to the **Load Balancing** page.
26+
27+
<DashButton url="/?to=/:account/load-balancing" />
28+
2. Select **Create load balancer**.
29+
3. Select **Public load balancer**.
30+
4. Choose the website to which you want to add this load balancer. To simplify DNS record management, we recommend using the same domain as your published application route.
31+
5. On the **Hostname** page, enter a hostname for the load balancer (for example, `lb.example.com`).
32+
6. On the **Pools** page, select **Create a pool**.
33+
7. Enter a descriptive name for the pool. For example, if you are configuring one pool per tunnel, the pool name can match your tunnel name.
34+
8. To add a tunnel endpoint to the pool, configure the following fields:
35+
- **Endpoint Name**: Name of the server that is running the application
36+
- **Endpoint Address**: `<UUID>.cfargotunnel.com`, where `<UUID>` is replaced by your Tunnel ID. You can find the **Tunnel ID** in [Zero Trust](https://one.dash.cloudflare.com) under **Networks** > **Tunnels**.
37+
- **Header value**: Hostname of your published application route (such as `app.example.com`). To find the hostname value, open your tunnel configuration and go to the **Published application routes** tab.
38+
- **Weight**: Assign a [weight](/load-balancing/understand-basics/traffic-steering/origin-level-steering/#weights) to the endpoint. If you only have one endpoint, enter `1`.
39+
9. (Recommended) On the **Monitors** page, attach a monitor to the tunnel endpoint. You can create the following monitor to check if the application is reachable:
40+
- **Type**: _HTTPS_
41+
- **Path**: `/`
42+
- **Port**: `443`
43+
- **Expected Code(s)**: `200`
44+
- **Header Name**: `Host`
45+
- **Value**: `app.example.com`
46+
47+
10. Save and deploy the load balancer.
48+
49+
To test the load balancer, access the application using the load balancer hostname (`lb.example.com`).
50+
51+
### Optional Cloudflare settings
52+
53+
The application will default to the Cloudflare settings for the load balancer hostname, including [cache rules](/cache/how-to/cache-rules/) and [firewall policies](/firewall/). You can change the settings for your hostname in the [Cloudflare dashboard](https://dash.cloudflare.com/).
1554

1655
## Common architectures
1756

@@ -31,12 +70,12 @@ graph LR
3170
P1 -- Tunnel 1 --> cf1
3271
P2 -- Tunnel 2 --> cf2
3372
subgraph D2[Private network]
34-
subgraph r1[Region eu-west]
73+
subgraph r1[Region eu-west-1]
3574
cf1@{ shape: processes, label: "cloudflared <br> **Route:** server1.example.com" }
3675
S1(["Server 1<br> 10.0.0.1:80"])
3776
cf1-->S1
3877
end
39-
subgraph r2[Region us-east]
78+
subgraph r2[Region us-east-1]
4079
cf2@{ shape: processes, label: "cloudflared <br> **Route:** server2.example.com" }
4180
S3(["Server 2 <br> 10.0.0.2:80"])
4281
cf2-->S3
@@ -90,50 +129,44 @@ good for an [Active-active](/load-balancing/load-balancers/common-configurations
90129
Active-active uses all available instances to process requests simultaneously, providing better performance and scalability by load-balancing traffic across them
91130

92131

93-
## Add a tunnel to a load balancer pool
94-
95-
<Tabs> <TabItem label="Dashboard">
96-
97-
To create a load balancer, refer to the [Load Balancing documentation](/load-balancing/load-balancers/create-load-balancer/). The endpoint address is the subdomain of your tunnel, `<UUID>.cfargotunnel.com`.
98-
99-
If you want to add a [monitor](/load-balancing/monitors/) to your load balancer pool, you will need to add a host header to **Advanced health check settings**. The header will be similar to `Header Name: Host` and `Value: www.your-zone.com`. The monitor will not work without the host header if you are using a config file that defines the `ingress` field, as shown in [this example](https://github.com/cloudflare/argo-tunnel-examples/blob/adb44da43ec0aa65f7928613b762a47ae0d9b2b0/named-tunnel-k8s/cloudflared.yaml#L90).
132+
Routes configured via the dashboard will automatically generate a `CNAME` record in the DNS zone that points to `<UUID>.cfargotunnel.com`. For example, if you add a tunnel route that points `app.example.com` to `localhost:80`, Cloudflare creates a `CNAME` record that points `app.example.com` to `<UUID.cfargotunnel.com`.
133+
Auto-generated DNS records:
100134

101-
</TabItem>
135+
| Type | Name | Content |
136+
| ---- | ---- | ------- |
137+
| LB | `lb.example.com` | n/a|
138+
| CNAME | app1 | `<UUID_1>.cfargotunnel.com` |
139+
| CNAME | app2 | `<UUID_1>.cfargotunnel.com` |
140+
| CNAME | app1 | `<UUID_2>.cfargotunnel.com` |
141+
| CNAME | app2 | `<UUID_2>.cfargotunnel.com` |
102142

103-
<TabItem label="cli">
143+
Updated DNS records:
104144

105-
You can add Cloudflare Tunnel to an existing load balancer pool directly from `cloudflared`:
106-
107-
```sh
108-
cloudflared tunnel route lb <tunnel name/uuid> <hostname> <load balancer pool>
109-
```
110-
111-
- `<hostname>`: the DNS hostname of the load balancer, for example `lb.example.com`.
112-
113-
- `<load balancer pool>`: the name of the [pool](/load-balancing/pools/create-pool/#create-a-pool) that will contain the tunnel subdomain.
114-
115-
This command creates an LB DNS record that points the specified hostname to the subdomain of your tunnel (`<UUID>.cfargotunnel.com`). Traffic will not be proxied unless the tunnel is running.
116-
117-
:::note
118-
119-
To create DNS records using `cloudflared`, the [`cert.pem`](/cloudflare-one/connections/connect-networks/do-more-with-tunnels/local-management/local-tunnel-terms/#certpem) file must be installed on your system.
120-
:::
121-
122-
</TabItem>
123-
124-
</Tabs>
125-
126-
## Optional Cloudflare settings
127-
128-
The application will default to the Cloudflare settings for the load balancer hostname, including [cache rules](/cache/how-to/cache-rules/) and [firewall policies](/firewall/). You can change the settings for your hostname in the [Cloudflare dashboard](https://dash.cloudflare.com/).
145+
| Type | Name | Content |
146+
| ---- | ---- | ------- |
147+
| LB | `lb.example.com` | n/a |
148+
| CNAME | app1 | `lb.example.com` |
149+
| CNAME | app2 | `lb.example.com` |
129150

130151
## Known limitations
131152

132-
### Monitors and TCP Tunnel origins
153+
### Monitors and TCP tunnel origins
154+
155+
If you have a tunnel to a port or SSH port, do not set up a [TCP monitor](/load-balancing/monitors/). Instead, set up a health check endpoint on the `cloudflared` host and create an HTTPS monitor. For example, you can use `cloudflared` to return a fixed HTTP status response:
133156

134-
If you have a tunnel to a port or SSH port, do not run a TCP health check.
157+
1. In your Cloudflare Tunnel, [add a published application route](/cloudflare-one/connections/connect-networks/get-started/create-remote-tunnel/#2a-publish-an-application) to represent the health check endpoint:
158+
- **Hostame**: Enter a hostname for the health check endpoint (for example, `health-check.example.com`)
159+
- **Service Type**: _HTTP_STATUS_
160+
- **HTTP Status Code**: `200`
161+
2. From the **Load Balancing** page, [create a monitor](/load-balancing/monitors/create-monitor/) with the following properties:
162+
- **Type**: _HTTPS_
163+
- **Path**: `/`
164+
- **Port**: `443`
165+
- **Expected Code(s)**: `200`
166+
- **Header Name**: `Host`
167+
- **Value**: `health-check.example.com`
135168

136-
Instead, set up a health check endpoint in `cloudflared` — for example, an [ingress entry rule](/cloudflare-one/connections/connect-networks/do-more-with-tunnels/local-management/configuration-file/#file-structure-for-public-hostnames) that returns a fixed HTTP status response — and create an **HTTP** [monitor](/load-balancing/monitors/) for that endpoint. The monitor will only verify that your server is reachable. It does not check whether the server is running and accepting requests.
169+
You can now assign this monitor to your load balancer endpoint. The monitor will only verify that your server is reachable. It does not check whether the server is running and accepting requests.
137170

138171
### Session affinity and replicas
139172

@@ -145,4 +178,4 @@ If you notice traffic imbalances across endpoints in different locations, you ma
145178

146179
`cloudflared` connections give preference to tunnels that terminate in the same Cloudflare data center. This behavior can impact how connections are weighted and traffic is distributed.
147180

148-
The solution depends on the type of tunnel being used. If running [legacy tunnels](/cloudflare-one/connections/connect-networks/do-more-with-tunnels/migrate-legacy-tunnels/), put your origins in different pools. If running [Cloudflare tunnel replicas](/cloudflare-one/connections/connect-networks/configure-tunnels/tunnel-availability/) (using a shared ID), switch to separate Cloudflare tunnels as distinct origins.
181+
The solution depends on the type of tunnel being used. If running [legacy tunnels](/cloudflare-one/connections/connect-networks/do-more-with-tunnels/migrate-legacy-tunnels/), put your origins in different pools. If running [`cloudflared` replicas](/cloudflare-one/connections/connect-networks/configure-tunnels/tunnel-availability/) (using a shared UUID), switch to separate Cloudflare tunnels as distinct origins.

0 commit comments

Comments
 (0)