GCP

Last updated Sep 11, 2026 This guide covers how to connect a Google Cloud Platform (GCP) virtual machine to Cloudflare using cloudflared and publish a web application through a Cloudflare Tunnel.

Prerequisites

1. Create a VM instance

  1. In your Google Cloud Console ↗︎, create a new project ↗︎.
  2. Go to Compute Engine > VM instances.
  3. Select Create instance.
  4. Name your VM instance. In this example we will name it http-test-server.
  5. Choose your desired operating system and specifications. For this example, you can use the following settings:
  6. Machine family: General Purpose
  7. Series: E2
  8. Machine type: e2-micro
  9. Boot disk image: Debian GNU/Linux 12
  10. Firewalls: Allow HTTP and HTTPS traffic
  11. Under Advanced options > Management > Automation, add the following startup script. This example deploys a basic Apache web server on port 80.

```bash #!/bin/bash apt update apt -y install apache2 cat < /var/www/html/index.html

Hello Cloudflare!

This page was created for a Cloudflare demo.

EOF ```

  1. Select Create.
  2. The operating system automatically starts the Apache HTTP server. To verify that the server is running:
  3. Copy the External IP for the VM instance.
  4. Open a browser and go to http://<EXTERNAL IP>. You should see the Hello Cloudflare! test page.
  5. To login to the VM instance, open the dropdown next to SSH and select Open in browser window.

2. Create a tunnel

  1. In the Cloudflare dashboard ↗︎, go to Networking > Tunnels.
  2. Select Create Tunnel and enter a name (for example, gcp-tunnel).
  3. Select Create Tunnel.
  4. Under Setup Environment, select Debian 64-bit.
  5. SSH into your VM and run the install commands shown in the dashboard.
  6. Once the tunnel connects, select Continue.

3. Publish an application

  1. Under Routes, select Add route > Published application.
  2. Enter a hostname (for example, hellocloudflare.<your-domain>.com).
  3. Under Service, enter http://localhost:80.
  4. Select Add route.

To test, open a browser and go to the hostname you configured.

You can optionally add Cloudflare Access to control who can reach the service.

Looking for private network access?

To connect to your VM via private IP using the Cloudflare One Client, refer to the Cloudflare One Tunnel documentation.

Firewall configuration

To secure your VM instance, you can configure your VPC firewall rules ↗︎ to deny all ingress traffic and allow only egress traffic to the Cloudflare Tunnel IP addresses. Since GCP denies ingress traffic by default ↗︎, you can delete all ingress rules and leave only the relevant egress rules.

Note

If you delete the default allow-ssh rule, you will be unable to SSH back into the VM.

After configuring your VPC firewall rules, verify that you can still access the service through Cloudflare Tunnel via its public hostname. The service should no longer be accessible from outside Cloudflare Tunnel -- for example, if you go to http://<EXTERNAL IP> the test page should no longer load.

Was this helpful?

YesNo

On this page

GCP - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/tunnel/guides/google-cloud-platform/#page","headline":"GCP","description":"Deploy Cloudflare Tunnel on Google Cloud Platform.","url":"https://developers.cloudflare.com/tunnel/guides/google-cloud-platform/","inLanguage":"en","image":"https://developers.cloudflare.com/tunnel/guides/google-cloud-platform/og.png?v=cfa97e9886604354","dateModified":"2026-09-11","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["GCP","Integration"]}


description: Scope Cloudflare member permissions to individual Cloudflare Tunnel instances. title: Granular permissions image: https://developers.cloudflare.com/tunnel/guides/granular-permissions/og.png?v=1e168858f6c9d7a7


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/tunnel/llms.txt
Use this file to discover all available pages before exploring further.