webshare/SETUP-GUIDE.md

165 lines
3.6 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.

# Webshare 代理通过 Tailscale + 甲骨文中转设置指南
## 架构说明
```
本地应用 → 本地SOCKS5(20001-20020) → Tailscale → 甲骨文节点(10001-10020) → Webshare代理
```
## 前置要求
1. 甲骨文服务器已安装 Tailscale 并连接到您的网络
2. 本地机器也已安装 Tailscale 并连接到同一网络
3. 两台机器都能正常通信
## 设置步骤
### 第一步:甲骨文服务器设置
1.`oracle-server-setup.sh` 上传到甲骨文服务器:
```bash
scp oracle-server-setup.sh user@your-oracle-server:~/
```
2. 在甲骨文服务器上运行:
```bash
chmod +x oracle-server-setup.sh
./oracle-server-setup.sh
```
3. 启动代理中转服务:
```bash
cd ~/proxy-config
./start-proxy-relay.sh
```
4. 记下显示的 Tailscale IP 地址100.64.0.1
### 第二步:本地设置
1. 运行本地客户端设置:
```bash
./local-client-setup.sh
```
输入甲骨文服务器的 Tailscale IP
2. 启动本地转发:
```bash
./start-local-forward.sh
```
3. 测试连接:
```bash
./test-proxies.sh
```
### 第三步:使用 Python 管理器(推荐)
更简单的方式是使用 Python 管理器:
```bash
# 安装依赖
pip3 install requests pyyaml
# 启动管理器(替换为实际的甲骨文 Tailscale IP
python3 proxy-manager.py 100.64.0.1
```
管理器会自动:
- 启动所有代理转发
- 测试连接状态
- 生成 Clash 配置文件
## 使用方式
### 直接使用 SOCKS5 代理
```bash
# 测试代理
curl --socks5 127.0.0.1:20001 http://httpbin.org/ip
# 使用不同代理
curl --socks5 127.0.0.1:20002 http://httpbin.org/ip
```
### 使用 Clash
```bash
# 使用生成的配置启动 Clash
clash -f clash-webshare-config.yaml
# 或使用自动生成的配置
clash -f clash-webshare-auto.yaml
```
### 在应用中使用
- **浏览器**:设置 SOCKS5 代理为 `127.0.0.1:20001-20020`
- **curl**`curl --socks5 127.0.0.1:20001 URL`
- **Python requests**
```python
proxies = {
'http': 'socks5://127.0.0.1:20001',
'https': 'socks5://127.0.0.1:20001'
}
requests.get('http://example.com', proxies=proxies)
```
## 端口分配
| 服务 | 端口范围 | 说明 |
|------|----------|------|
| 甲骨文中转 | 10001-10020 | 接收本地连接,转发到 Webshare |
| 本地代理 | 20001-20020 | 本地应用连接这些端口 |
| Clash HTTP | 7890 | Clash HTTP 代理端口 |
| Clash SOCKS | 7891 | Clash SOCKS 代理端口 |
## 故障排除
### 1. 连接失败
- 检查 Tailscale 连接:`tailscale status`
- 检查甲骨文服务器防火墙
- 确认甲骨文服务器代理服务正在运行
### 2. 代理不工作
- 检查 Webshare 账号状态
- 测试单个 Webshare 代理是否可用
- 查看 gost 进程是否正常运行:`ps aux | grep gost`
### 3. 性能优化
- 根据需要调整代理数量
- 使用负载均衡模式分散请求
- 监控代理使用情况
## 管理命令
```bash
# 查看运行状态
ps aux | grep gost
# 停止所有代理
pkill -f gost
# 重启服务(在甲骨文)
cd ~/proxy-config && ./start-proxy-relay.sh
# 重启本地转发
./start-local-forward.sh
```
## 安全注意事项
1. 确保 Tailscale 网络安全
2. 不要将代理端口暴露到公网
3. 定期更新 Webshare 账号凭证
4. 监控代理使用情况,避免滥用
## 自动化启动
### 甲骨文服务器systemd 服务)
```bash
sudo systemctl enable webshare-proxy
sudo systemctl start webshare-proxy
```
### 本地(可选)
创建开机启动脚本或使用 crontab。
---
**提示**:首次设置建议先手动运行各个步骤,确认工作正常后再设置自动启动。