Skip to content

Commit 0d5cbd7

Browse files
update step 2
1 parent 3d23847 commit 0d5cbd7

File tree

1 file changed

+68
-66
lines changed

1 file changed

+68
-66
lines changed

src/content/docs/cloudflare-one/connections/connect-networks/get-started/create-remote-tunnel-api.mdx

Lines changed: 68 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ Follow this guide to set up a Cloudflare Tunnel using the API.
1313

1414
[Create an API token](/fundamentals/api/get-started/create-token/) with the following permissions:
1515

16-
| Type | Item | Permission |
17-
| ------- | ---------------- | ---------- |
18-
| Account | Cloudflare Tunnel | Edit |
19-
| Zone | DNS | Edit |
16+
| Type | Item | Permission |
17+
| ------- | ----------------- | ---------- |
18+
| Account | Cloudflare Tunnel | Edit |
19+
| Zone | DNS | Edit |
2020

2121
## 2. Create a tunnel
2222

23-
Make a `POST` request to the [Cloudflare Tunnel](/api/resources/zero_trust/subresources/access/subresources/applications/methods/create/) endpoint:
23+
Make a `POST` request to the [Cloudflare Tunnel](/api/resources/zero_trust/subresources/tunnels/subresources/cloudflared/methods/create/) endpoint:
2424

2525
```sh
2626
curl 'https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/cfd_tunnel' \
@@ -76,47 +76,48 @@ Follow these steps to connect an application through your tunnel. If you are loo
7676

7777
1. Make a [`PUT` request](/api/resources/zero_trust/subresources/tunnels/subresources/cloudflared/subresources/configurations/methods/update/) to route your local service URL to a public hostname. For example,
7878

79-
```sh
80-
curl --request PUT \
81-
'https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/cfd_tunnel/c1744f8b-faa1-48a4-9e5c-02ac921467fa/configurations' \
82-
--header 'Content-Type: application/json' \
83-
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
84-
--data '{
85-
"config": {
86-
"ingress": [
87-
{
88-
"hostname": "app.example.com",
89-
"service": "http://localhost:8001",
90-
"originRequest": {}
91-
},
92-
{
93-
"service": "http_status:404"
94-
}
95-
]
96-
}
97-
}'
98-
```
99-
100-
:::note
101-
If you add a multi-level subdomain (more than one level of subdomain), you must [order an Advanced Certificate for the hostname](/cloudflare-one/faq/troubleshooting/#i-see-this-site-cant-provide-a-secure-connection).
102-
:::
103-
104-
Your ingress rules must include a catch-all rule at the end. In this example, `cloudflared` will respond with a 404 status code when the request does not match any of the previous hostnames.
79+
```sh
80+
curl --request PUT \
81+
'https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/cfd_tunnel/c1744f8b-faa1-48a4-9e5c-02ac921467fa/configurations' \
82+
--header 'Content-Type: application/json' \
83+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
84+
--data '{
85+
"config": {
86+
"ingress": [
87+
{
88+
"hostname": "app.example.com",
89+
"service": "http://localhost:8001",
90+
"originRequest": {}
91+
},
92+
{
93+
"service": "http_status:404"
94+
}
95+
]
96+
}
97+
}'
98+
```
99+
100+
:::note
101+
If you add a multi-level subdomain (more than one level of subdomain), you must [order an Advanced Certificate for the hostname](/cloudflare-one/faq/troubleshooting/#i-see-this-site-cant-provide-a-secure-connection).
102+
:::
103+
104+
Your ingress rules must include a catch-all rule at the end. In this example, `cloudflared` will respond with a 404 status code when the request does not match any of the previous hostnames.
105105

106106
2. [Create a DNS record](/api/resources/dns/subresources/records/methods/create/) for your application:
107-
```sh
108-
curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records \
109-
--header 'Content-Type: application/json' \
110-
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
111-
--data '{
112-
"type": "CNAME",
113-
"proxied": true,
114-
"name": "app.example.com",
115-
"content": "c1744f8b-faa1-48a4-9e5c-02ac921467fa.cfargotunnel.com"
116-
}'
117-
```
118-
119-
This DNS record allows Cloudflare to proxy `app.example.com` traffic to your Cloudflare Tunnel (`<tunnel-id>.cfargotunnel.com`).
107+
108+
```sh
109+
curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records \
110+
--header 'Content-Type: application/json' \
111+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
112+
--data '{
113+
"type": "CNAME",
114+
"proxied": true,
115+
"name": "app.example.com",
116+
"content": "c1744f8b-faa1-48a4-9e5c-02ac921467fa.cfargotunnel.com"
117+
}'
118+
```
119+
120+
This DNS record allows Cloudflare to proxy `app.example.com` traffic to your Cloudflare Tunnel (`<tunnel-id>.cfargotunnel.com`).
120121

121122
This application will be publicly available on the Internet once you [run the tunnel](#4-install-and-run-the-tunnel). To allow or block specific users, [create an Access application](/cloudflare-one/applications/configure-apps/self-hosted-public-app/).
122123

@@ -143,46 +144,47 @@ Install `cloudflared` on your server and run the tunnel using the `token` value
143144

144145
<Tabs> <TabItem label="Windows">
145146

146-
1. [Download and install](/cloudflare-one/connections/connect-networks/downloads/#windows) `cloudflared`.
147+
1. [Download and install](/cloudflare-one/connections/connect-networks/downloads/#windows) `cloudflared`.
147148

148-
2. Open Command Prompt as administrator.
149+
2. Open Command Prompt as administrator.
149150

150-
3. Run the following command:
151+
3. Run the following command:
151152

152-
```txt
153-
cloudflared.exe service install <tunnel-token>
154-
```
153+
```txt
154+
cloudflared.exe service install <tunnel-token>
155+
```
155156

156157
</TabItem> <TabItem label="macOS">
157158

158-
1. [Download and install](/cloudflare-one/connections/connect-networks/downloads/#macos) `cloudflared`.
159+
1. [Download and install](/cloudflare-one/connections/connect-networks/downloads/#macos) `cloudflared`.
159160

160-
2. Run the following command:
161+
2. Run the following command:
161162

162-
```sh
163-
sudo cloudflared service install <tunnel-token>
164-
```
163+
```sh
164+
sudo cloudflared service install <tunnel-token>
165+
```
165166

166167
</TabItem> <TabItem label="Linux">
167168

168-
1. [Download and install](https://pkg.cloudflare.com/index.html) `cloudflared`.
169+
1. [Download and install](https://pkg.cloudflare.com/index.html) `cloudflared`.
169170

170-
2. Run the following command:
171+
2. Run the following command:
171172

172-
```sh
173-
sudo cloudflared service install <tunnel-token>
174-
```
173+
```sh
174+
sudo cloudflared service install <tunnel-token>
175+
```
175176

176177
</TabItem> <TabItem label="Docker">
177178

178-
1. Open a terminal window.
179+
1. Open a terminal window.
180+
181+
2. Run the following command:
179182

180-
2. Run the following command:
183+
```sh
184+
docker run cloudflare/cloudflared:latest tunnel --no-autoupdate run --token <tunnel-token>
185+
```
181186

182-
```sh
183-
docker run cloudflare/cloudflared:latest tunnel --no-autoupdate run --token <tunnel-token>
184-
```
185-
</TabItem> </Tabs>
187+
</TabItem> </Tabs>
186188

187189
## 5. Verify tunnel status
188190

0 commit comments

Comments
 (0)