Tạo Proxy trên VPS bằng Squid cùng VPSTTT

Video hướng dẫn tạo proxy bằng squid

Mục Lục Tạo Proxy

1. Chuẩn bị để tạo proxy

VPS Chạy hệ điều hành Centos 7 cấu hình tối thiểu 1 vCPU và 512 mb Ram và phần mềm điều khiển có thể là BvSshClient (492 downloads) hoặc putty (181 downloads) .

2. Bắt đầu

Sau khi kết nói tới VPS bạn chạy lệnh cài đặt Squid :

				
					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
				
			
				
					vi /etc/squid/squid.conf
				
			

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_CỦA BẠN
				
			

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/basic_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/basic_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
				
			

3. Nhiều Proxy / 1 VPS

				
					http_port ip:port name=proxy1
acl proxy1 myip ip
tcp_outgoing_address ip proxy1
				
			

mở file /ect/squid/squid.conf

Định cấu hình IP bổ sung trong Squid

Xóa http_port 3128 thay bằng

http_port ip:port name=proxy1

acl proxy1 myip ip

tcp_outgoing_address ip proxy1

  • Trong đó proxy1 là tên của proxy có ip đó tùy bạn đặt
  • ip bạn thay bằng ip của vps, port là port mà bạn muốn

Ví dụ

http_port 51.199.10.15:3128 name=proxy1

acl proxy1 myip 51.199.10.15

tcp_outgoing_address 51.199.10.15 proxy1

Để thêm các IP khác, chỉ cần sao chép phần và chỉnh sửa nó với các chi tiết IP khác của bạn. Ở đây tôi đã thêm hai IP nữa vào tệp squid.conf

http_port 51.199.10.15:3128 name=proxy1
acl proxy1 myip 51.199.10.15
tcp_outgoing_address 51.199.10.15 proxy1

http_port 51.199.10.15:3128 name=proxy2
acl proxy2 myip 51.199.10.16
tcp_outgoing_address 51.199.10.16 proxy2

http_port 51.199.10.17:3128 name=proxy3
acl proxy3 myip 51.199.10.17
tcp_outgoing_address 51.199.10.17 proxy3

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
				
			

Link check proxy IPv4 : https://proxy6.net/en/checker

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!

Proxy-Server-1