Hướng dẫn tạo SOCKS Proxy trên VPS

VIDEO THAM KHẢO


Chuẩn bị về VPS

  • Nếu bạn đã có vps thì có thể dùng chung vì nó sẽ không ảnh hướng quá nhiều tới VPS.
  • Chọn các nhà cung cấp VPS chất lượng giá rẻ tại THẾ GIỚI SỐ để có tốc độ truy cập tốt nhất.
  • Vps có Ram > 512mb, đường truyền >= 10Mbps, CentOS 6 hoặc 7 đều được.

Dùng Squid tạo Proxy Server trên VPS

Squid là một phần mềm Proxy Server dùng cho việc lưu trữ cache và lọc nội dung web. Squid hỗ trợ các giao thức HTTP, HTTPS, FTP,… Nguyên tắc hoạt động của Squid là khi người dùng truy vấn đến 1 website thông qua Squid thì Squid sẽ kiểm tra xem nội dung trang web đó có được lưu trữ và có thay đổi không? Nếu đã có lưu trữ và không thay đổi thì Squid sẽ trả luôn nội dung đó cho người dùng mà không cần phải truy vấn đến địa chỉ website kia nữa. Điều này giúp quá trình duyệt web nhanh hơn rất nhiều.

Có rất nhiều phần mềm có thể giúp bạn tạo Proxy server nhưng theo mình phần mềm tốt nhất đó là Squid. Vì nó ổn định, đáng tin cậy và có nhiều chức năng. Và điều quan trọng nhất khi nói về các phần mềm trên linux, đa số là miễn phí và Squid cũng là một phần mềm như vậy. Squid cũng có một phiên bản trên windows nhưng mình nghĩ bạn nên sử dụng phiên bản trên Linux thì tốt hơn là chạy trên windows. ISA server không bao giờ là một lựa chọn tốt nhất cả.

Hướng dẫn chi tiết cách tạo SOCKS Proxy trên VPS

Để cài đặt Squid Proxy trên CentOS bạn đăng nhập vào VPS bằng PutTy và thực hiện lệnh sau :

yum install -y squid

Cấu hình để Squid để tự động chạy mỗi khi Server khởi động lại với lệnh sau:

chkconfig squid on
service squid start

Thông tin cấu hình cho Squid sẽ được chứa trong file /etc/squid/squid.conf. Mặc định Squid sẽ chạy trên port 3128, nếu bạn muốn Squid chạy trên port khác thì mở file /etc/squid/squid.conf và tìm dòng sau để thay đổi http_port 3128

Bạn sửa http_access deny all thành http_access allow all

Để tăng tính bảo mật cho Proxy của bạn, bạn nên tạo user để sử dụng proxy của bạn. Bạn thực hiện lệnh này:

yum install -y httpd-tools
touch /etc/squid/squid_passwd
chown squid /etc/squid/squid_passwd

Sau đó, bạn chạy câu lệnh này để tạo user, hệ thống sẽ yêu cầu bạn nhập mật khẩu:

htpasswd /etc/squid/squid_passwd user_cuaban

Với Debian và Ubuntu

dpkg -L squid | grep ncsa_auth

RHEL/CentOS/Fedora

rpm -ql squid | grep ncsa_auth

Kết quả báo ( dùng nó để thêm ở bước sau)

/usr/lib64/squid/ncsa_auth

Sau đó thêm vào dòng đầu của file /etc/squid/squid.conf với nội dung sau :

auth_param basic program /usr/lib64/squid/ncsa_auth /etc/squid/squid_passwd
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users

Ngoài ra, để sử dụng Squid làm Proxy mà không muốn bị phát hiện ra là bạn dùng proxy thì bạn thêm vào cuối file /etc/squid/squid.conf nội dung sau :

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

Sau đó khởi động lại Squid để các cấu hình trên có hiệu lực :

service squid restart

Nếu bạn không muốn sử dụng Proxy server bằng VPS của mình, ta có thẻ remove xóa Squid ra khỏi VPS bằng lệnh sau:

yum remove squid -y

Vậy là xong hướng dẫn chi tiết cách tạo SOCKS Proxy trên VPS. Chúc các bạn thành công!

 

5 1 đánh giá
Article Rating
Theo dõi
Thông báo của
guest
0 Comments
Phản hồi nội tuyến
Xem tất cả bình luận