GAppProxy (Google App Engine Proxy) 利用 Google App Engine 免費額度搭建代理通道,客戶端原生提供 Windows GUI,Linux 下需使用 Python 版客戶端或第三方 GUI 包裝。本文詳細說明 Python 客戶端部署、配置檔詳解、FetchServer 版本對應、systemd 服務化、常見連線問題排查與開源 GUI 替代方案。
fetchserver-2.0.0 源碼app.yaml:application: your-project-idgcloud app deploy (舊版 appcfg.py update fetchserver-2.0.0)https://your-project-id.appspot.com/fetch.py 回傳 GAppProxy Fetch Server
# 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_server | FetchServer 完整 URL (必須 HTTPS) | https://xxx.appspot.com/fetch.py |
常見錯誤:fetch_server 使用 https:// 而非 https://,導致 GAE 拒絕連線;local_proxy 格式錯誤 (缺少 :// 或認證格式)。
# /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
127.0.0.1:8000,勾選「也用於 FTP」--proxy-server=127.0.0.1:8000 (Linux 啟動參數)127.0.0.1:8000export 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 重寫客戶端 |
git clone https://github.com/xxx/gappproxy-linux-gui
pip install -r requirements.txt
python main.py
功能:狀態指示燈、一鍵啟停、自動重連、開機自啟勾選
# 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 免費額度帶來的代理自由。