Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 系統配置 GAppProxy 客戶端完整教學 (Python 版 + GUI 替代方案)

編輯:Linux 教學

GAppProxy (Google App Engine Proxy) 利用 Google App Engine 免費額度搭建代理通道,客戶端原生提供 Windows GUI,Linux 下需使用 Python 版客戶端或第三方 GUI 包裝。本文詳細說明 Python 客戶端部署、配置檔詳解、FetchServer 版本對應、systemd 服務化、常見連線問題排查與開源 GUI 替代方案。

前置準備:FetchServer 部署 (GAE)

  1. 申請 Google Cloud 專案,啟用 App Engine
  2. 下載 fetchserver-2.0.0 源碼
  3. 修改 app.yaml:application: your-project-id
  4. 部署:gcloud app deploy (舊版 appcfg.py update fetchserver-2.0.0)
  5. 驗證:https://your-project-id.appspot.com/fetch.py 回傳 GAppProxy Fetch Server

Python 客戶端部署


# 1. 下載
wget https://gappproxy.googlecode.com/files/localproxy-2.0.0.tar.gz
tar -xzf localproxy-2.0.0.tar.gz
cd localproxy-2.0.0

# 2. 依賴 (Python 2.7/3.x 均可)
# pip install -r requirements.txt  # 通常無額外依賴

# 3. 配置 proxy.conf
cat > proxy.conf <

關鍵配置項詳解 proxy.conf

參數說明範例
listen_port本地監聽埠 (HTTP/HTTPS 代理)8000
local_proxy上游代理 (若公司強制走 HTTP 代理)user:pass@10.0.0.1:3128
fetch_serverFetchServer 完整 URL (必須 HTTPS)https://xxx.appspot.com/fetch.py

常見錯誤:fetch_server 使用 https:// 而非 https://,導致 GAE 拒絕連線;local_proxy 格式錯誤 (缺少 :// 或認證格式)。

systemd 服務化 (開機自啟、後台常駐)


# /etc/systemd/system/gappproxy.service
[Unit]
Description=GAppProxy Local Client
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=proxyuser
Group=proxyuser
WorkingDirectory=/opt/gappproxy/localproxy-2.0.0
ExecStart=/usr/bin/python3 proxy.py
Restart=on-failure
RestartSec=5
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target

systemctl daemon-reload
systemctl enable --now gappproxy
journalctl -u gappproxy -f

瀏覽器/系統代理設定

  • Firefox:設定 → 一般 → 網路代理 → 手動設定 → HTTP/HTTPS/SOCKS 皆填 127.0.0.1:8000,勾選「也用於 FTP」
  • Chrome/Edge:系統代理設定 (Windows) / --proxy-server=127.0.0.1:8000 (Linux 啟動參數)
  • 全系統 (GNOME/KDE):網路 → 網路代理 → 手動 → 所有協定 127.0.0.1:8000
  • 命令列工具:export http_proxy=https://127.0.0.1:8000 https_proxy=https://127.0.0.1:8000

常見問題排查表

現象原因解決
瀏覽器開啟網頁一片空白FetchServer 版本不匹配 (客戶端 2.x 對應 Server 2.x)重新部署 FetchServer 2.0+,確認 URL 正確
SSL 憑證驗證失敗Python 版本過舊 / CA 憑證缺失更新 ca-certificates、使用 Python 3.8+
連線超時GFW 封鎖 GAE IP / 公司防火牆封鎖 443啟用 local_proxy 走公司 HTTP 代理
CPU 佔用異常高Python 解析器效能 / 大量並發限制並發、改用 Go/Rust 重寫客戶端

開源 GUI 替代方案 (系統匣圖 + 一鍵開關)

  1. Gappproxy-linux-gui (Python + PyQt5)
    
      git clone https://github.com/xxx/gappproxy-linux-gui
      pip install -r requirements.txt
      python main.py
      
    功能:狀態指示燈、一鍵啟停、自動重連、開機自啟勾選
  2. Shadowsocks-Qt5 / ShadowsocksX-NG 通用代理客戶端,支援 HTTP/HTTPS/SOCKS5 代理鏈,可將 GAppProxy 作為上游
  3. Proxychains-ng + Rofi/dmenu:終端機快速切換代理模式

進階:多 FetchServer 負載均衡與容錯


# proxy.conf 多伺服器輪詢 (需客戶端支援,或自行實作輪詢器)
fetch_server = https://proj1.appspot.com/fetch.py
fetch_server = https://proj2.appspot.com/fetch.py
fetch_server = https://proj3.appspot.com/fetch.py

若官方客戶端不支援多伺服器,可撰寫簡單 Shell/Python 守護程式,定期健檢並切換 proxy.conf 後 systemctl reload gappproxy。

掌握 Python 客戶端部署、systemd 服務化、FetchServer 版本對應與 GUI 替代方案,即可在 Linux 桌面/伺服器環境穩定運行 GAppProxy,享受 GAE 免費額度帶來的代理自由。

Copyright © Windows教程網 All Rights Reserved