You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Automatic configuration for private databases on Hyperdrive
3
+
description: Hyperdrive now automatically configures your Cloudflare Tunnel to connect to your private database.
4
+
products:
5
+
- hyperdrive
6
+
date: 2025-01-22T18:00:00Z
7
+
---
8
+
9
+
Hyperdrive now automatically configures your Cloudflare Tunnel to connect to your private database.
10
+
11
+

12
+
13
+
When creating a Hyperdrive configuration for a private database, you only need to provide your database credentials and set up a Cloudflare Tunnel within the private network where your database is accessible. Hyperdrive will automatically create the Cloudflare Access, Service Token and Policies needed to secure and restrict your Cloudflare Tunnel to the Hyperdrive configuration.
14
+
15
+
To create a Hyperdrive for a private database, you can follow the [Hyperdrive documentation](/hyperdrive/configuration/connect-to-private-database/). You can still manually create the Cloudflare Access, Service Token and Policies if you prefer.
16
+
17
+
This feature is available from the Cloudflare dashboard.
title: Hyperdrive automatically configures your Cloudflare Tunnel to connect to your private database.
10
+
description: |-
11
+
When creating a Hyperdrive configuration for a private database, you only need to provide your database credentials and set up a Cloudflare Tunnel within the private network where your database is accessible.
12
+
13
+
Hyperdrive will automatically create the Cloudflare Access, Service Token and Policies needed to secure and restrict your Cloudflare Tunnel to the Hyperdrive configuration.
14
+
15
+
Refer to [documentation on how to configure Hyperdrive to connect to a private database](/hyperdrive/configuration/connect-to-private-database/).
8
16
- publish_date: "2024-12-11"
9
17
title: Hyperdrive now caches queries in all Cloudflare locations decreasing cache hit latency by up to 90%
Copy file name to clipboardExpand all lines: src/content/docs/hyperdrive/configuration/connect-to-private-database.mdx
+31-5Lines changed: 31 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,30 @@ Your tunnel must be configured to use a public hostname so that Hyperdrive can r
52
52
If you are setting up the tunnel through the CLI instead ([locally-managed tunnel](/cloudflare-one/connections/connect-networks/configure-tunnels/local-management/)), you will have to complete these steps manually. Follow the Cloudflare Zero Trust documentation to [add a public hostname to your tunnel](/cloudflare-one/connections/connect-networks/routing-to-tunnel/dns/) and [configure the public hostname to route to the address of your database](/cloudflare-one/connections/connect-networks/configure-tunnels/local-management/configuration-file/).
53
53
:::
54
54
55
-
## 2. Create a service token
55
+
## 2. Create and configure Hyperdrive to connect to the Cloudflare Tunnel
56
+
57
+
To restrict access to the Cloudflare Tunnel to Hyperdrive, a [Cloudflare Access application](/cloudflare-one/applications/) must be configured with a [Policy](/cloudflare-one/policies/) that requires requests to contain a valid [Service Auth token](/cloudflare-one/policies/access/#service-auth).
58
+
59
+
The Cloudflare dashboard can automatically create and configure the underlying [Cloudflare Access application](/cloudflare-one/applications/), [Service Auth token](/cloudflare-one/policies/access/#service-auth) and [Policy](/cloudflare-one/policies/) on your behalf. Alternatively, you can manually create the Access application and configure the Policies.
60
+
61
+
<Tabs> <TabItemlabel="Automatic creation">
62
+
63
+
### 2.1 Create a Hyperdrive configuration in the Cloudflare dashboard
64
+
65
+
Create a Hyperdrive configuration in the Cloudflare dashboard to automatically configure Hyperdrive to connect to your Cloudflare Tunnel.
66
+
67
+
1. In the [Cloudflare dashboard](https://dash.cloudflare.com/?to=/:account/workers/hyperdrive), navigate to **Storage & Databases > Hyperdrive** and click **Create configuration**.
68
+
1. Select **Private database**.
69
+
1. In the **Networking details** section, select the tunnel you are connecting to.
70
+
1. In the **Networking details** section, select the hostname associated to the tunnel. (If there is no hostname for your database, return to step [1.2. Connect your database using a public hostname](#12-connect-your-database-using-a-public-hostname)).
71
+
1. In the **Access Service Authentication Token** section, select **Create new (automatic)**.
72
+
1. In the **Access Application** section, select **Create new (automatic)**.
73
+
74
+
1. In the **Database connection details** section, enter the database **name**, **user**, and **password**.
75
+
76
+
</TabItem>
77
+
<TabItemlabel="Manual creation">
78
+
### 2.1 Create a service token
56
79
57
80
The service token will be used to restrict requests to the tunnel, and is needed for the next step.
58
81
@@ -72,7 +95,7 @@ The service token will be used to restrict requests to the tunnel, and is needed
72
95
This is the only time Cloudflare Access will display the Client Secret. If you lose the Client Secret, you must regenerate the service token.
73
96
:::
74
97
75
-
##3. Create an Access application to secure the tunnel
98
+
### 2.2 Create an Access application to secure the tunnel
76
99
77
100
[Cloudflare Access](/cloudflare-one/policies/access/) will be used to verify that requests to the tunnel originate from Hyperdrive using the service token created above.
78
101
@@ -110,7 +133,7 @@ The service token will be used to restrict requests to the tunnel, and is needed
110
133
111
134
17. Save the application.
112
135
113
-
##4. Create a Hyperdrive configuration
136
+
### 2.3 Create a Hyperdrive configuration
114
137
115
138
To create a Hyperdrive configuration for your private database, you'll need to specify the Access application and Cloudflare Tunnel information upon creation.
116
139
@@ -152,7 +175,9 @@ In addition, it will also set the Access Client ID and the Access Client Secret
152
175
When creating the Hyperdrive configuration for the private database, you must enter the `access-client-id` and the `access-client-id`, and omit the `port`. Hyperdrive will route database messages to the public hostname of the tunnel, and the tunnel will rely on its service configuration (as configured in [1.2. Connect your database using a public hostname](#12-connect-your-database-using-a-public-hostname)) to route requests to the database within your private network.
153
176
:::
154
177
155
-
## 5. Query your Hyperdrive configuration from a Worker (optional)
178
+
</TabItem> </Tabs>
179
+
180
+
## 3. Query your Hyperdrive configuration from a Worker (optional)
156
181
157
182
To test your Hyperdrive configuration to the database using Cloudflare Tunnel and Access, use the Hyperdrive configuration ID in your Worker and deploy it.
158
183
@@ -177,4 +202,5 @@ If you successfully receive the list of `pg_tables` from your database when you
177
202
## Troubleshooting
178
203
179
204
If you encounter issues when setting up your Hyperdrive configuration with tunnels to a private database, consider these common solutions, in addition to [general troubleshooting steps](/hyperdrive/observability/troubleshooting/) for Hyperdrive:
180
-
* Ensure your database is configured to use TLS (SSL). Hyperdrive requires TLS (SSL) to connect.
205
+
206
+
- Ensure your database is configured to use TLS (SSL). Hyperdrive requires TLS (SSL) to connect.
0 commit comments