Ở bài viết trước mình đã hướng dẫn fake IP bằng SSH với Bitvise SSH Client, các bạn có thể tham khảo. Trong bài viết này mình hướng dẫn thêm 1 cách tạo Proxy Server, bạn không cần dùng phần mềm thứ 3 để ẩn IP nữa.
Proxy Server là gì?
Proxy Server có thể được hiểu như 1 server trung gian có nhiệm vụ chuyển tiếp thông tin từ máy client tới các tài nguyên trên mạng Internet. Nó bao gồm 1 địa chỉ IP cố định (Public IP) và 1 cổng dịch vụ trên Server đó.
Squid HTTP Proxy Server là gì?
Squid là một proxy lưu trữ (caching proxy) cho Web, hỗ trợ HTTP, HTTPS, FTP, và nhiều cái khác. Nó giúp giảm băng thông và cải thiện thời gian phản hồi bằng cách lưu trữ và sử dụng các truy vấn web thường xuyên.
Cài đặt Squid HTTP Proxy Server
Đầu tiên bạn cần có 1 VPS tối thiểu 512MB ram, bạn có thể sử dụng VPS tại Vultr, Linode Hoặc Upcloud.
Xem thêm: VPS Chất Lượng Tốt Nhất Nên Dùng
Để cài đặt Squid trên CentOS bạn có thể dùng file cài đặt mình tạo sẵn, bạn tải về tại đây upload lên vps tại thư mục root và dùng lệnh chmod +x squid-install.sh && ./squid-install.sh
. Đợi cài đặt xong bạn điền password cho user Halazy.
Để kiểm tra dịch vụ proxy server đã hoạt động chưa sử dụng command sau:
systemctl status squid
Cấu hình Squid HTTP Proxy Server
Mặc định Squid sẽ chạy mặc định trên cổng 3128 chúng ta có thể thay thế hoặc thêm công mới bằng cách thêm dòng sau (VD: port 8080 ) vào file /etc/squid/squid.conf
http_port 8080
Tiếp tục sửa đoạn sau từ: http_access deny all
thành http_access allow all
Thêm đoạn sau vào cuối file giúp proxy ẩn danh hơn
via off forwarded_for off request_header_access Allow allow all request_header_access Authorization allow all request_header_access WWW-Authenticate allow all request_header_access Proxy-Authorization allow all request_header_access Proxy-Authenticate allow all request_header_access Cache-Control allow all request_header_access Content-Encoding allow all request_header_access Content-Length allow all request_header_access Content-Type allow all request_header_access Date allow all request_header_access Expires allow all request_header_access Host allow all request_header_access If-Modified-Since allow all request_header_access Last-Modified allow all request_header_access Location allow all request_header_access Pragma allow all request_header_access Accept allow all request_header_access Accept-Charset allow all request_header_access Accept-Encoding allow all request_header_access Accept-Language allow all request_header_access Content-Language allow all request_header_access Mime-Version allow all request_header_access Retry-After allow all request_header_access Title allow all request_header_access Connection allow all request_header_access Proxy-Connection allow all request_header_access User-Agent allow all request_header_access Cookie allow all request_header_access All deny all
Thêm đoạn này vào sau acl CONNECT method CONNECT
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
Tiến hành mở port nếu VPS chặn port bạn muốn sử dụng
sudo firewall-cmd --zone=public --add-port=3128/tcp --permanent sudo firewall-cmd --reload
Kiểm tra xem port đã được mở chưa
sudo iptables-save | grep 3128
Nếu trả về kết quả -A IN_public_allow -p tcp -m tcp --dport 3128 -m conntrack --ctstate NEW,UNTRACKED -j ACCEPT
thì được nhé.
DISABLE IPv6
sudo nano /etc/sysctl.conf
Thêm vào cuối đoạn sau:
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
Ctrl + O để lưu lại, Ctrl + X để thoát ra
Cuối cùng tiến hành restart squid
sudo systemctl restart squid
Chúc bạn thành công!