zh

VPS代理服务器:SOCKS5和HTTP代理搭建

代理服务器是实现网络匿名和访问控制的基础工具。SOCKS5代理支持所有类型的网络流量(TCP和UDP),HTTP代理则专注于HTTP/HTTPS请求。在自己的离岸VPS上搭建代理服务器,相比使用公共代理,能提供完整的隐私保障和访问速度控制。本指南涵盖主流代理服务器软件的安装、配置和安全加固。

Need this done for your project?

We implement, you ship. Async, documented, done in days.

Start a Brief

安装Dante搭建SOCKS5代理

Dante是最稳定的开源SOCKS5服务器实现。安装并配置带认证的SOCKS5代理:
apt install -y dante-server
# 获取网卡名称
ip a | grep "state UP"
编辑「/etc/danted.conf」:
logoutput: syslog
internal: 0.0.0.0 port = 1080
external: eth0
clientmethod: none
socksmethod: username
user.privileged: root
user.unprivileged: nobody

client pass {
  from: 0.0.0.0/0 to: 0.0.0.0/0
  log: error
}
socks pass {
  from: 0.0.0.0/0 to: 0.0.0.0/0
  socksmethod: username
  log: error
}
创建代理用户:
useradd -r -s /bin/false proxyuser
echo "proxyuser:StrongPassword123" | chpasswd
systemctl enable --now danted
连接格式:「socks5://proxyuser:StrongPassword123@VPS_IP:1080」

使用3proxy搭建HTTP/HTTPS代理

3proxy是轻量级的多协议代理服务器,支持HTTP、SOCKS4、SOCKS5:
apt install -y 3proxy
# 配置文件 /etc/3proxy/3proxy.cfg
cat > /etc/3proxy/3proxy.cfg << 'EOF'
daemon
nserver 1.1.1.1
nscache 65536
timeouts 1 5 30 60 180 1800 15 60
log /var/log/3proxy/3proxy.log D
rotate 30
auth strong cache
users proxyuser:CL:YourPassword
allow *

proxy -p8080
socks -p1080
EOF
3proxy支持ACL规则,可限制特定IP或域名的访问,适合团队共享代理场景。 通过SSH隧道加密代理连接(在不支持原生加密的场景下):
ssh -D 1080 -N -f user@VPS_IP -p 4499
这会在本地创建一个SOCKS5代理,所有流量通过SSH加密隧道传输到VPS。

代理安全加固与访问控制

开放在公网上的代理服务器面临被滥用的风险。以下措施能有效防止未授权使用: IP白名单访问控制(只允许特定IP连接代理):
# ufw规则,只允许YOUR_HOME_IP访问代理端口
ufw allow from YOUR_HOME_IP to any port 1080
ufw allow from YOUR_HOME_IP to any port 8080
ufw deny 1080
ufw deny 8080
使用fail2ban防止暴力破解:
apt install -y fail2ban
# 创建3proxy规则
cat > /etc/fail2ban/jail.d/3proxy.conf << 'EOF'
[3proxy]
enabled = true
port = 1080,8080
filter = 3proxy
logpath = /var/log/3proxy/3proxy.log
maxretry = 5
bantime = 3600
EOF
systemctl restart fail2ban
定期审查代理日志检测异常流量,Anubiz Host VPS支持每月重置流量计数,方便监控代理使用量是否超出预期。

Why Anubiz Host

100% async — no calls, no meetings
Delivered in days, not weeks
Full documentation included
Production-grade from day one
Security-first approach
Post-delivery support included

Ready to get started?

Skip the research. Tell us what you need, and we'll scope it, implement it, and hand it back — fully documented and production-ready.

Anubiz Chat AI

Online