Bước 1: Tạo VPS
Tạo 1 VPS cấu hình thấp nhất, giá tiền rẻ nhất vì proxy không cần cấu hình cao. Chọn OS là Almalinux 8 hoặc Centos.
Ở đây mình sử dụng VPS của Vultr để làm ví dụ – Ngoài ra bạn có thể chọn các VPS trong nước đều được.
Bước 2: Check IP Blacklist
Sau khi tạo VPS, điều đầu tiên bạn nên làm là vào MXToolBox check xem IP có bị blacklist ko nhé. IP bị blacklist sẽ ảnh hưởng tới chất lượng proxy và dễ bị block acc nếu sử dụng IP này.
Bước 3: Upload Script lên VPS
Download Script ở đây (Ctrl + S để lưu về máy) và upload vào thư mục Root trên VPS. Bạn có thể sử đụng Bitvise để đăng nhập vào VPS and upload Script. Cái này cơ bản bạn nào chưa biết thì google search nhe.
Bên dưới là script mình tự code. Script sạch nên các bạn yên tâm. 1 chức năng duy nhất là cài Squid Proxy và những thứ liên quan. Chạy 1 lệnh mất tầm 2-3p là có proxy xài luôn.
Mở script bằng notepad và đổi username, password và port cho proxy trong phần Variables.
Sau khi cài đặt thành công proxy sẽ có dạng IP:port:username:password.
#!/bin/bash
# Variables
username="doi_username"
password="doi_password"
http_port="doi_port"
# Step 1: Check if Squid is already installed
if ! rpm -q squid > /dev/null 2>&1; then
echo "Installing Squid..."
yum -y update
yum -y install squid
systemctl start squid
systemctl enable squid
systemctl status squid
else
echo "Squid is already installed. Skipping installation."
fi
# Step 2: Check if httpd-tools is already installed
if ! rpm -q httpd-tools > /dev/null 2>&1; then
echo "Installing httpd-tools..."
yum -y install httpd-tools
else
echo "httpd-tools is already installed. Skipping installation."
fi
# Set up username and password for the Squid proxy
echo "Setting up username and password..."
sudo touch /etc/squid/passwd && chown squid /etc/squid/passwd
echo "$password" | htpasswd -i /etc/squid/passwd $username
# Step 3: Configuration
echo "Configuring Squid..."
config_file="/etc/squid/squid.conf"
# Change http_port
sed -i "s/http_port 3128/http_port $http_port/" $config_file
# Change http_access to allow all
sed -i 's/http_access deny all/http_access allow all/' $config_file
# Add the recommended minimum configuration if they don't exist
config_lines=(
"auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd"
"auth_param basic children 5"
"auth_param basic realm Squid Basic Authentication"
"auth_param basic credentialsttl 2 hours"
"acl auth_users proxy_auth REQUIRED"
"http_access allow auth_users"
)
for line in "${config_lines[@]}"; do
if ! grep -Fxq "$line" $config_file; then
echo "$line" >> $config_file
fi
done
# Step 4: Check if CSF is installed
if ! command -v csf > /dev/null 2>&1; then
echo "CSF not found. Installing CSF..."
# Download and install CSF
cd /usr/src
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh
# Verify CSF installation
if ! command -v csf > /dev/null 2>&1; then
echo "Error: CSF installation failed."
exit 1
fi
else
echo "CSF is already installed. Skipping installation."
fi
# Step 5: Add port to TCP_IN in /etc/csf/csf.conf and reload CSF
echo "Adding port $http_port to TCP_IN in /etc/csf/csf.conf..."
csf_config="/etc/csf/csf.conf"
if [ -f "$csf_config" ]; then
if ! grep -w -q "$http_port" "$csf_config"; then
sed -i "/TCP_IN =/ s/\"$/,$http_port\"/" "$csf_config"
# Reload CSF without printing results
sudo csf -r > /dev/null 2>&1
else
echo "Port $http_port is already in CSF configuration."
fi
else
echo "Error: CSF configuration file not found."
exit 1
fi
# Reload CSF without printing results
sudo csf -r > /dev/null 2>&1
# Step 6: Disable IPv6
echo "Disabling IPv6..."
sysctl_config="/etc/sysctl.conf"
# Add IPv6 disable settings if not present
if ! grep -q "net.ipv6.conf.all.disable_ipv6" $sysctl_config; then
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> $sysctl_config
fi
if ! grep -q "net.ipv6.conf.default.disable_ipv6" $sysctl_config; then
echo "net.ipv6.conf.default.disable_ipv6 = 1" >> $sysctl_config
fi
# Apply sysctl settings
sudo sysctl -p
# Step 7: Restart Squid
echo "Restarting Squid..."
systemctl restart squid
systemctl status squid
echo "Squid installation and configuration complete.
Bước 4: Cấp quyền cho script
Login vào SSH bằng Bitvise với user root. Chạy lệnh bên dưới để cấp quyền cho script chạy.
chmod +x /root/setup_squid_proxy.sh
Bước 5: Chạy Script tạo proxy
Giờ chỉ cần chạy script và chờ thành quả. Sau 2-3p là bạn đã có 1 dedicated proxy.
/root/setup_squid_proxy.sh
Đợi vài phút cho script cài đặt Squid Proxy. Bạn thấy giống hình bên dưới là proxy đã đc tạo thành công.
Bước 6: Sử dụng proxy
Có proxy rồi giờ bạn muốn làm gì thì làm. Mình thì cài extension Proxy SwichyOmega để gắn proxy vào Chrome.
Vào whatismyipaddress.com check xem IP đã đổi chưa nhé.
Chúc bạn thành công!