سرور پروکسی روی VPS: SOCKS5 و HTTP
پروکسی SOCKS5 و HTTP سادهترین و سریعترین راه برای هدایت ترافیک از طریق یک سرور خارجی هستند. برخلاف VPN که کل ترافیک سیستم را تغییر میدهد، پروکسیها میتوانند فقط برای برنامههای خاص تنظیم شوند. کاربردهای رایج شامل web scraping، botting، اتصال به سرویسهای خارجی از ایران و دور زدن محدودیتهای IP است.
Need this done for your project?
We implement, you ship. Async, documented, done in days.
نصب SOCKS5 با Dante
Dante یکی از پیادهسازیهای SOCKS5 پایدار و امن است:
apt update
apt install -y dante-serverپیکربندی Dante در /etc/danted.conf:
logoutput: /var/log/danted.log
internal: 0.0.0.0 port = 1080
external: eth0
socksmethod: username
clientmethod: none
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
}systemctl enable danted
systemctl start dantedاحراز هویت کاربر برای SOCKS5
ایجاد کاربر سیستمی برای پروکسی (بدون دسترسی shell):
useradd -r -s /bin/false proxyuser
passwd proxyuserتست اتصال از terminal:
curl -x socks5h://proxyuser:password@VPS_IP:1080 https://api.ipify.orgاگر IP سرور VPS نشان داده شد، پروکسی درست کار میکند.
تنظیم در Python requests:
import requests
proxies = {
'http': 'socks5h://proxyuser:password@VPS_IP:1080',
'https': 'socks5h://proxyuser:password@VPS_IP:1080',
}
response = requests.get('https://api.ipify.org', proxies=proxies)
print(response.text)نصب HTTP Proxy با Squid
Squid برای HTTP/HTTPS proxy کاربردهای گستردهتری دارد:
apt install -y squid apache2-utilsایجاد فایل پسورد:
htpasswd -c /etc/squid/passwd proxyuserپیکربندی Squid در /etc/squid/squid.conf:
auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic realm Proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated
http_access deny all
http_port 3128
dns_nameservers 1.1.1.1 8.8.8.8systemctl enable squid
systemctl restart squidتست:
curl -x http://proxyuser:password@VPS_IP:3128 https://api.ipify.orgتنظیمات فایروال و محدودیت دسترسی
محدود کردن دسترسی به IPهای خاص (امنترین روش):
ufw allow from YOUR_HOME_IP to any port 1080
ufw allow from YOUR_OFFICE_IP to any port 1080
ufw deny 1080
ufw allow from YOUR_HOME_IP to any port 3128
ufw deny 3128اگر IP شما ثابت نیست، rate limiting برای جلوگیری از سوء استفاده:
# در squid.conf
delay_pools 1
delay_class 1 1
delay_parameters 1 -1/-1
delay_access 1 allow authenticatedلاگهای اتصالات:
tail -f /var/log/squid/access.logVPS آفشور Anubiz Host در ایسلند IPهای clean با هیچ blacklist ندارند - ایدهآل برای web scraping و اتصال به سرویسهای خارجی از ایران.
Related Services
Why Anubiz Host
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.