vi

Proxy Server Tự Host Trên VPS Offshore

Proxy server là công cụ thiết yếu cho nhiều use case: vượt qua geo-restriction, anonymize traffic, scrape web, kiểm thử ứng dụng từ các vùng địa lý khác nhau. Tự dựng proxy server trên VPS offshore Iceland của AnubizHost mang lại proxy riêng tư hoàn toàn - không log, không chia sẻ với người dùng khác, không phụ thuộc commercial proxy service có thể bán lại data của bạn. Bài viết hướng dẫn các stack phổ biến: Squid HTTP proxy, Dante SOCKS5, và MITM Proxy cho debugging/analysis.

Need this done for your project?

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

Start a Brief

Khi Nào Tự Host Proxy Tốt Hơn Commercial

Commercial proxy services (Bright Data, Smartproxy, Oxylabs, ProxyMesh) cung cấp hàng triệu IP với pool rotation tự động, phù hợp cho large-scale scraping. Tuy nhiên, có ba nhược điểm quan trọng:

Privacy concerns: Commercial proxy provider thấy được toàn bộ traffic của bạn nếu họ muốn (HTTP plaintext, hoặc TLS decryption nếu họ là MITM proxy). Có lịch sử các provider bán data này cho bên thứ ba hoặc bị data breach.

Cost: Residential proxy giá $5-15/GB. Scrape 1TB/tháng có thể tốn $5000-15000. Self-host trên VPS offshore $7.99-29.99/tháng với bandwidth không giới hạn.

IP reputation: Pool IP commercial bị nhiều người dùng đồng thời, một số dùng để scrape Amazon dữ liệu sai mục đích hoặc spam. IP bị flag - khi đến lượt bạn dùng, IP đã bad reputation.

Tự host phù hợp khi:

  • Cần 1-10 IP cố định cho specific use case (không cần rotation lớn).
  • Privacy là ưu tiên cao - dùng cho personal browsing, business sensitive traffic.
  • Volume traffic lớn nhưng số endpoint nhỏ (vượt geo-block cho streaming service).
  • Test app từ specific country (Iceland, Romania, Ukraine - tùy location VPS).

Commercial proxy phù hợp khi:

  • Cần hàng nghìn IP rotation cho large-scale scraping anti-bot.
  • Cần residential IP (không phải datacenter) - VPS provider thường không cung cấp residential.
  • Volume cao trên short-term, không muốn manage infrastructure.

Cài Đặt Squid HTTP/HTTPS Proxy

Squid là HTTP/HTTPS proxy mature, được sử dụng trong enterprise hơn 20 năm. Cài đặt trên Ubuntu:

apt update && apt install -y squid apache2-utils
nano /etc/squid/squid.conf

Cấu hình cơ bản với basic auth:

http_port 3128

# Auth via htpasswd
auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic realm Anubiz Proxy
auth_param basic credentialsttl 24 hours

acl authenticated proxy_auth REQUIRED

# Whitelist client IP (nếu muốn IP-based auth thay vì user/pass)
# acl trusted_clients src YOUR_HOME_IP/32

http_access allow authenticated
http_access deny all

# Privacy: hide client real IP
forwarded_for delete
via off
request_header_access X-Forwarded-For deny all

# Cache disable (nếu chỉ dùng làm proxy, không cache)
cache deny all

Tạo user proxy:

htpasswd -c /etc/squid/passwd alice
# Nhập password

Khởi động Squid:

systemctl restart squid
ufw allow 3128/tcp

Test bằng curl:

curl -x http://alice:PASSWORD@VPS_IP:3128 https://ifconfig.me

Output sẽ là IP của VPS Iceland, không phải IP của bạn. Cấu hình tương tự trong Firefox/Chrome/system proxy settings.

HTTPS proxy: Squid mặc định CONNECT-tunnel HTTPS (forward bytes raw, không inspect). Để inspect HTTPS (legitimate cho corporate environment), cần SSL bumping với CA cert được trust trên client - complex setup, ít dùng cho personal use.

SOCKS5 Proxy với Dante và MITM Proxy

SOCKS5 proxy linh hoạt hơn HTTP proxy - hỗ trợ mọi giao thức (HTTP, HTTPS, SMTP, IMAP, XMPP, BitTorrent). Dante là Dante SOCKS5 server phổ biến nhất:

apt update && apt install -y dante-server
nano /etc/danted.conf

Cấu hình:

logoutput: syslog
internal: 0.0.0.0 port = 1080
external: eth0

socksmethod: username
user.privileged: root
user.notprivileged: nobody

client pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    log: connect disconnect error
}

socks pass {
    from: 0.0.0.0/0 to: 0.0.0.0/0
    log: connect disconnect error
    socksmethod: username
}

Tạo user system cho SOCKS auth:

useradd -r -s /bin/false sock5user
echo "sock5user:STRONG_PASSWORD" | chpasswd

Khởi động Dante:

systemctl enable --now danted
ufw allow 1080/tcp

Test:

curl --socks5 sock5user:PASSWORD@VPS_IP:1080 https://ifconfig.me

MITM Proxy cho debugging: mitmproxy là tool đặc biệt cho phép intercept, inspect, modify HTTP/HTTPS traffic. Dùng cho debug mobile app, phân tích API third-party, security testing apps của riêng bạn.

apt install -y mitmproxy
mitmproxy --listen-host 0.0.0.0 --listen-port 8080

Trên client, set proxy HTTPS = VPS_IP:8080. Cài CA cert của mitmproxy (tải từ http://mitm.it qua proxy) để decode HTTPS. Mọi request hiện trong terminal UI realtime - có thể edit body/header on-the-fly.

Security note: MITM proxy nguy hiểm nếu dùng sai cách - không cài CA của mitmproxy vào trust store của thiết bị/người khác. Chỉ dùng cho debug app/system của riêng bạn với consent.

Logging và privacy: Đối với personal proxy server, disable verbose logging trong Squid/Dante. Chỉ log error, không log URL truy cập. Đảm bảo system log không lưu lâu dài. Iceland luật bảo vệ data nghiêm ngặt - dù log có, cũng không thể bàn giao tùy tiện.

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