---
title: "Building a NAT Traversal Server (Frp Server) on Google Cloud Platform"
description: "A step-by-step guide on how to create an Ubuntu VM on Google Cloud Platform, install and configure an FRP Server, and set up a stable, low-cost intranet penetration service."
canonical_url: "https://blog.markkulab.net/en/post/frps"
author: "Mark Ku"
author_url: "https://blog.markkulab.net/en/author/mark-ku"
site: "Mark Ku's Tech Notes"
date_published: "2024-10-01 01:01:35 +0800"
category: "Cloud"
tags: ["frp", "frps", "reverse proxy", "gcp", "nat traversal", "self-hosted", "linux", "cloud"]
language: "en"
license: "CC BY 4.0"
license_url: "https://creativecommons.org/licenses/by/4.0/"
attribution: "when reusing or quoting, credit the author and link back to the original"
---

# Building a NAT Traversal Server (Frp Server) on Google Cloud Platform

## Solving the Problem
[A previous article](https://blog.markkulab.net/2021/05/31/frpc/) introduced how to use a free Frps reverse proxy server to expose an internal network website. However, because the free service is very unstable, my blog and demo sites often went down. Later, a netizen recommended Google's 90-day free trial, which includes a $300 credit. This article will show you how to set up your own NAT traversal server (FRPS) using GCP (Google Cloud).

## First, sign up for a GCP account and link your credit card

## Log in to the GCP console > VM instances
![GCP Compute Engine VM instances with Create instance button](https://blog.markkulab.net/content/markku/posts/frps/images/LNph6ly.webp)

## Select Taiwan as the region and Ubuntu as the operating system. Since I only need a reverse proxy and don't require complex computations, I'll choose the f1-micro instance. The estimated monthly cost is only about 15X NTD, which is quite affordable.
![Google Cloud Platform VM creation UI, f1-micro instance, $5.6](https://blog.markkulab.net/content/markku/posts/frps/images/qtpWIMy.png)

## Once the instance is created, find "VPC network" in the menu and change the instance's IP to static. This will prevent the IP address from changing.
![GCP console external IP address dropdown menu to reserve static IP](https://blog.markkulab.net/content/markku/posts/frps/images/PukFeHZ.webp)

![Google Cloud dialog to reserve static IP for frp-server](https://blog.markkulab.net/content/markku/posts/frps/images/TyPfbfU.webp)

## Go back to VM instances and open an SSH connection to the newly created instance.
![Google Cloud VM instances page with SSH connection options](https://blog.markkulab.net/content/markku/posts/frps/images/AuSmzRf.webp)

## A browser-based SSH session will open. Enter the following Linux commands in order.

Update the system

```
sudo apt-get update
sudo apt-get upgrade
```

FRP is written in Go. Most Linux distributions come with Go pre-installed, but if yours doesn't, you can run the following command first:

```
sudo apt-get install bison ed gawk gcc libc6-dev make golang-go vim
```

Next, you need to go to the FRP GitHub repository to find the latest version of frps and download it.

```
wget https://github.com/fatedier/frp/releases/download/v0.62.1/frp_0.62.1_linux_amd64.tar.gz
```

Unzip the file and rename the folder to `frp`.

```
tar -zxvf frp_0.62.1_linux_amd64.tar.gz
sudo mkdir /var/frps
sudo mv frp_0.62.1_linux_amd64/* /var/frps/
cd /var/frps
```

Edit the frps configuration file (`sudo vim frps.toml`).

```
# frps.toml
bindAddr = "0.0.0.0"
bindPort = 7000
vhostHttpPort = 80
vhostHttpsPort = 443
webServer = { port = 7500, user = "admin", password = "your password", addr="0.0.0.0" }
auth.method = "token"
auth.token = "your token"
```

Run it.
```
sudo ./frps -c ./frps.toml
```

## Configure the domain in your DNS host
![Frps server logs showing successful startup and multiple proxy creations](https://blog.markkulab.net/content/markku/posts/frps/images/wxhxp8T.webp)

First, create a DNS A record to point `proxy.markkulab.net` to the external IP of the FRPS server.
![DNS A record form with host 'proxy' and IP '34.80](https://blog.markkulab.net/content/markku/posts/frps/images/Br3Kpe1.webp)
Next, create a CNAME record. This way, when a visitor accesses `blog.markkulab.net`, frps will point them to the website mapped by the specified client.
![CNAME record form for blog pointing to proxy.markkulab.net](https://blog.markkulab.net/content/markku/posts/frps/images/WHDoSYy.webp)

![CNAME record form with host 'shop' and target 'proxy.markkulab.net](https://blog.markkulab.net/content/markku/posts/frps/images/7iCNmjK.webp)

## frpc.toml Configuration

```
serverAddr = "35.223.172.254"
serverPort = 7000
auth.token = "your token"
transport.poolCount = 10000

[[proxies]]
name = "test-tcp"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 6000

[[proxies]]
name = "ShopCarthttps1"
type = "http"
customDomains = ["www.letgo.com.tw"]
localPort = 8896

[[proxies]]
name = "linebot"
type = "https"
customDomains = ["linebot.letgo.com.tw"]
[proxies.plugin]
type = "https2http"
localAddr = "127.0.0.1:48002"
crtPath = "/Public/!.letgo.com.tw/fullchain.crt"
keyPath = "/Public/!.letgo.com.tw/cert.key"
hostHeaderRewrite = "linebot.letgo.com.tw"
requestHeaders.set.x-from-where = "frp"
```
## If you need it to start automatically on reboot, you need to register it as a service.
### Add a configuration file in `/lib/systemd/system/`
```
sudo vim /lib/systemd/system/frps.service
```
Create the auto-start configuration file.
```
[Unit]
Description=FRP Server
After=network.target
Wants=network.target

[Service]
Restart=on-failure
RestartSec=5
ExecStart=/var/frps/frps -c /var/frps/frps.toml

[Install]
WantedBy=multi-user.target
```
### Start the service
```
sudo systemctl daemon-reload  // reload service
sudo systemctl stop frps.service //停止 FRP Server 服務
sudo systemctl start frps.service //啟動 FRP Server 服務
sudo systemctl restart frps.service //重啟 FRP Server 服務
sudo systemctl disable frps.service //開機時不要啟動 FRP Server 服務
sudo systemctl enable frps.service //開機時自動啟動 FRP Server 服務
sudo systemctl status frps.service //查看FRP Server 狀態
```
## Test if the firewall is disabled
Test if the firewall is disabled on Windows.
```
telnet 35.223.172.254  7000
```
Test if the firewall is enabled on Linux.
```
nc -zv 127.0.0.1 7000
```
## Remember to configure the GCP firewall, otherwise it won't be accessible from the public internet. Go back to the instance details and modify the "Network tags" for the changes to take effect.
![GCP firewall rule details for frps, allowing all protocols](https://blog.markkulab.net/content/markku/posts/frps/images/disable-gcp-firewall.png)

## Next, find an Ubuntu machine to install frpc
### Create a directory
```
sudo mkdir -p /etc/frp
```
### Download FRP 0.62.1 and unzip it
```
cd /etc/frp
sudo wget https://github.com/fatedier/frp/releases/download/v0.62.1/frp_0.62.1_linux_amd64.tar.gz
sudo tar -zxvf frp_0.62.1_linux_amd64.tar.gz --strip-components=1
```
### Create the frpc.toml configuration file
```
sudo vim /etc/frp/frpc.toml
```
frpc.toml
```
serverAddr = "your server"
serverPort = 7000
auth.token = "your token"
transport.poolCount = 10000

[[proxies]]
name = "jks"
type = "https"
customDomains = ["jks.letgo.com.tw"]
[proxies.plugin]
type = "https2http"
localAddr = "127.0.0.1:8080"
crtPath = "/var/frpc/letgo/fullchain.crt"
keyPath = "/var/frpc/letgo/cert.key"
hostHeaderRewrite = "jks.letgo.com.tw"
requestHeaders.set.x-from-where = "frp"
```
### Test
```
/etc/frp/frpc -c /etc/frp/frpc.toml
```
### Set up auto-start on boot
```
sudo vim /lib/systemd/system/frpc.service
```
### Create the auto-start configuration file
```
[Unit]
Description=FRP Client
After=network.target
Wants=network.target

[Service]
Restart=on-failure
RestartSec=5
ExecStart=/etc/frp/frpc -c /etc/frp/frpc.toml

[Install]
WantedBy=multi-user.target
```
### Start the service
```
sudo systemctl daemon-reload  // reload service
sudo systemctl stop frpc.service //停止 FRP Server 服務
sudo systemctl start frpc.service //啟動 FRP Server 服務
sudo systemctl restart frpc.service //重啟 FRP Server 服務
sudo systemctl disable frpc.service //開機時不要啟動 FRP Server 服務
sudo systemctl enable frpc.service //開機時自動啟動 FRP Server 服務
sudo systemctl status frpc.service //查看FRP Server 狀態
```
## Finally
In the end, I created the VM in the Taiwan region. I've heard Google's data center is in Chiayi, and the network speed is super fast and very stable. For about 150 NTD per month, you get a reverse proxy and a static IP, which is actually a pretty good deal.
![Browser displaying an e-commerce website selling dried fruit](https://blog.markkulab.net/content/markku/posts/frps/images/G28BhNe.webp)

## Addendum - GCP Free Tier
[Free Tier Link](https://cloud.google.com/free/docs/gcp-free-tier/?hl=zh-CN#compute)

After the free trial period ends, we can still use certain products for free within specified usage limits. For example, the popular Google Compute Engine offers the following free conditions:

Only in the US regions "us-central1", "us-east1", and "us-west1".
* 1 f1-micro instance per month
* 30 GB of HDD storage per month
* 1 GB of network egress per month (from North America to all regions except China and Australia)

Even if you host an f1 instance in Taiwan, the cost is only about 5.6 * 27.82 (USD exchange rate) = ~155 NTD per month.
![Google Cloud f1-micro instance setup in Taiwan, $5.60 monthly cost](https://blog.markkulab.net/content/markku/posts/frps/images/nGMDwz8.png)

---

## About this article and its author

Originally published on [Mark Ku's Tech Notes](https://blog.markkulab.net/en/post/frps)

License: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) — when reusing or quoting, credit the author and link back to the original

### About the author

**[Mark Ku](https://blog.markkulab.net/en/author/mark-ku)** — Software Solution Provider

- 10+ years senior software engineer, now an AI Builder
- Focused on large-platform architecture — North-American e-commerce, AI SaaS subscription billing
- Combining AI Agents and automation to build evolvable product foundations

### Free tools built by the author

All of these are free to use:

- [Free PDF Sign Tool](https://blog.markkulab.net/en/tools/pdf-sign): Online PDF sign tool — draw, type, or upload a signature, then drag, resize, and download. Everything runs in your browser; nothing is uploaded.
- [VS Code Refactory](https://blog.markkulab.net/en/tools/refactory): Refactory is a VS Code refactoring extension: 34 actions plus a 37-rule code-smell inspection layer with a Code Health dashboard, across 18 languages, backed by 534 tests. It learns your repo's conventions: where interfaces live, where DI is registered, whether 'use client' belongs. It ranks files by git churn × complexity so you know what to fix first, and hands any smell to the Claude Code already on your machine. Free to use, and your source never leaves your computer.
- [DB-Kit Database Manager](https://blog.markkulab.net/en/tools/db-kit): DB-Kit is a lightweight, cross-platform database manager built with Tauri + Rust + React. Manage MySQL, MariaDB, PostgreSQL, SQL Server, Oracle, SQLite, MongoDB, Redis, Kafka, Elasticsearch and RabbitMQ from one consistent interface: passwords encrypted in the OS keychain, SSH tunnels, full CRUD, a visual query builder, stacked multi-statement result sets, cross-connection data transfer and compare/sync, Excel / CSV import & export, visualized execution plans, ER diagrams, scheduled backups, SQL stress testing with p50–p99 latency percentiles, a 15-rule SQL review engine, Kafka message browsing with monitoring & alerts, a bilingual UI (Traditional Chinese / English), a built-in AI assistant (natural-language SQL, AI review and tuning advice) and the dbk CLI. Free and open source (MIT), with installers for Windows, macOS and Linux.
- [VS Code Super Mermaid](https://blog.markkulab.net/en/tools/super-mermaid): Super Mermaid is a VS Code extension for beautiful Mermaid diagrams out of the box: auto-colored live preview, mouse pan & zoom, high-res PNG / SVG export, 21 templates and multiple themes. Free and open source (MIT).
- [React Super Mermaid](https://blog.markkulab.net/en/tools/react-super-mermaid): react-super-mermaid is an open-source React component library: render beautiful Mermaid diagrams with a single <MermaidViewer>, with built-in colorful / sketch themes, pan & zoom, in-diagram search, and high-res SVG / PNG export. Lightweight, SSR-safe, fully typed. Free and open source (MIT).
- [Jira / Confluence Super Mermaid](https://blog.markkulab.net/en/tools/jira-super-mermaid): An Atlassian Forge app: write Mermaid syntax directly inside a Jira issue or a Confluence page and get flowcharts, sequence diagrams, state machines and Gantt charts. 11 diagram types, SVG / PNG export, light and dark themes, full CJK support. Runs on Atlassian: your diagrams live in your own site and the app calls no third-party service. Free, coming soon to the Atlassian Marketplace.
- [Mermaid Live Preview](https://blog.markkulab.net/en/tools/mermaid-preview): Write Mermaid in your browser, see it render instantly, and share the whole diagram as a single link. No sign-up, nothing uploaded to a server, and mermaid.live share links work as-is.
- [React Intl Phone Number](https://blog.markkulab.net/en/tools/react-intl-phone-number): react-intl-phone-number is an open-source React component: framework-agnostic and antd-free, with E.164 in/out, a searchable flag / country-code dropdown, configurable validation levels (strict / mobile-strict / loose), themeable CSS, and i18n — phone logic powered by google-libphonenumber. Lightweight and fully typed. Free and open source (MIT).
- [Uptime Kuma Cluster](https://blog.markkulab.net/en/tools/uptime-kuma-cluster): Turn single-node Uptime Kuma into a highly available cluster: OpenResty + Lua smart load balancing, shared MariaDB state, health checks and automatic failover, plus cluster-management REST APIs. One Docker Compose command to start. Free and open source (MIT).
- [Special Education](https://blog.markkulab.net/en/education): Learning materials crafted for special education students

### Daily podcasts

- [Mark's Tech Insights — Daily AI News](https://blog.markkulab.net/en/category/tech-news): Daily curated AI and tech trends. Catch the latest developments via audio summaries — covering AI applications, software architecture, DevOps, and engineering practice. — RSS: https://blog.markkulab.net/feed.xml
- [AI股市蝦聊](https://blog.markkulab.net/en/category/ai-stock-chat): Every trading day, an AI-analyzed take on the Taiwan stock market, delivered as a two-host conversation covering the session and the next-day outlook. — RSS: https://blog.markkulab.net/ai-stock-chat/feed.xml
- [開源好物週報](https://blog.markkulab.net/en/category/open-source-weekly): A weekly two-host pick of free open-source tools surfaced from real Hacker News, GitHub, and Reddit buzz — what pain they solve and the fastest way to get started. — RSS: https://blog.markkulab.net/open-source-weekly/feed.xml

### Newsletter

[Subscribe to the newsletter](https://blog.markkulab.net/en/subscribe) — Be the first to know about new posts. No spam, unsubscribe anytime.
