FRP 內網穿透工具教學與平台支援

作者:

分類:

FRP 內網穿透工具教學

要架設 frp (fast reverse proxy),你需要兩台機器:

  • FRP Server (frps):一台有「公網 IP」的伺服器(通常是雲端主機 VPS)。
  • FRP Client (frpc):你在內網的機器(例如 Surface)。

目前 frp 新版本(v0.52.0 之後)建議使用 .toml 格式的設定檔,以下是基本配置教學:

第一步:下載 frp

兩台機器都要下載對應版本的 frp(GitHub Release 頁面)。解壓縮後你會看到 frps(伺服器端程式)和 frpc(客戶端程式)。

第二步:設定伺服器端 (frps)

# frps.toml
bindPort = 7000          # frp 服務運行的通訊埠

# 認證密鑰
auth.token = "你的隨機密碼"

# 選配:儀表板 (Dashboard)
webServer.addr = "0.0.0.0"
webServer.port = 7500
webServer.user = "admin"
webServer.password = "admin_password"

啟動指令:./frps -c frps.toml

第三步:設定客戶端 (frpc)

# frpc.toml
serverAddr = "你的 VPS 公網 IP"
serverPort = 7000
auth.token = "你的隨機密碼"

[[proxies]]
name = "ssh"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 6000

[[proxies]]
name = "openclaw-ui"
type = "tcp"
localIP = "127.0.0.1"
localPort = 18789
remotePort = 18789

啟動指令:./frpc -c frpc.toml


FRP Docker 部署範例

使用 Docker Compose 部署 frp 是最簡單且穩定的方式。以下是 docker-compose.yml 範例:

services:
  # --- FRP Server (雲端主機 VPS 使用) ---
  frps:
    image: snowdreamtech/frps:latest
    container_name: frps
    restart: always
    network_mode: host
    volumes:
      - ./frps.toml:/etc/frp/frps.toml

  # --- FRP Client (內網機器 使用) ---
  # frpc:
  #   image: snowdreamtech/frpc:latest
  #   container_name: frpc
  #   restart: always
  #   network_mode: host
  #   volumes:
  #     - ./frpc.toml:/etc/frp/frpc.toml

💡 提示: 建議使用 network_mode: host,這樣就不需要手動在 Compose 檔案中對應每一個轉發的 Port。


Docker 實用小技巧 (Debian/Linux)

如何確認 Docker 是否正在執行?

在 Debian 13 或大多數 Linux 系統中,可以使用以下指令:

  • 查看詳細狀態sudo systemctl status docker (看到 active (running) 代表正常)。
  • 快速檢查sudo systemctl is-active docker
  • 內部驗證sudo docker info

遇到「Cannot connect to the Docker daemon」?

如果你確認 Docker 正在執行但還是看到這個錯誤,通常是權限問題。請在指令前加上 sudo,或者將使用者加入 docker 群組。


FRP Server 支援平台

frps (Server 端) 的相容性非常廣,基本上只要有 公網 IP 的裝置都能跑:

  • 作業系統:Linux (Ubuntu, Debian, CentOS), Windows, macOS, FreeBSD。
  • 硬體架構:x86/x64, ARM/ARM64 (樹莓派), MIPS, RISC-V。
  • 部署情境:雲端 VPS (AWS, GCP, Oracle Cloud), Docker (NAS), 帶公網 IP 的路由器 (OpenWrt)。

(最後更新:2026-02-06 by Heathcliff)


留言

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *