Files
knowledge-base/AI/tokyo-proxy/01-proxy.md

83 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 东京云服务器代理方案
## 场景
国内访问 GitHub / Docker Hub 速度慢,用东京低配云服务器做流量转发。
## 服务端(东京服务器)
### 1. 安装 squid
```bash
apt update && apt install -y squid apache2-utils
```
### 2. 配置 squid密码认证
```bash
cat > /etc/squid/squid.conf << 'EOF'
http_port 3128
auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic realm "Tokyo Proxy"
acl auth proxy_auth REQUIRED
http_access allow auth
http_access deny all
EOF
```
### 3. 创建用户
```bash
htpasswd -cb /etc/squid/passwd 用户名 密码
```
### 4. 重启
```bash
systemctl restart squid
systemctl enable squid
```
### 验证
```bash
ss -tlnp | grep 3128
```
---
## 国内客户端
### Docker 配置
```bash
mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/http-proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=http://用户名:密码@东京服务器IP:3128"
Environment="HTTPS_PROXY=http://用户名:密码@东京服务器IP:3128"
EOF
systemctl daemon-reload && systemctl restart docker
```
### Git 配置
```bash
git config --global http.proxy http://用户名:密码@东京服务器IP:3128
git config --global https.proxy http://用户名:密码@东京服务器IP:3128
```
### 取消代理(如需直连)
```bash
git config --global --unset http.proxy
git config --global --unset https.proxy
# Docker 删除 /etc/systemd/system/docker.service.d/http-proxy.conf 后重启
```
---
## 验证
```bash
docker pull nginx
git clone https://github.com/torvalds/linux
```
---
## 注意事项
- 东京服务器带宽低1-2MbpsDocker 拉大镜像较慢
- Git 流量小,代理无压力
- HTTP 代理同时支持 Git 和 Docker无需 nginx 反代