Hướng dẫn cài đặt và cấu hình Squid HTTP Proxy Server trên CentOS 7 8 / RHEL 7 ubuntu

23/12/2020

Giới thiệu

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,… giúp bạn tiết kiệm băng thông và tăng tốc độ truy cập web.
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ài đặt Squid  ubuntu

Các tính năng chính :

  1. Addiptoserver
  2. Showavailableproxies
  3. Adduser
  4. Assigniptouser
  5. Showsusersexpiredate
  6. Modifyusersexpirydate
  7. Showusersproxyinfo
  8. Deleteipfromserver
  9. Deleteuserproxy
  10. Deleteuser
  11. Shutdownproxy
  12. Startproxy
  13. Exportavailableproxy
  14. Exportusersproxy
  15. Addblacklist
  16. Showblacklist
  17. Deleteblacklist
  18. Exit
  19. Randomproxies
  20. Changeip-multiplier

Cài đặt Squid Proxy Manager

apt-get update
sudo apt install git
git clone https://github.com/khacnam/squid.git
cd squid
chmod 0755 initialize.sh
chmod 0755 proxy.sh
./initialize.sh

Manager proxy :

./proxy.sh

Cài đặt Squid trên CentOS

Bước 1: Cài đặt Squid

yum install -y squid

Bước 2: start squid

service squid start

Bước 3:  Thiết lập file cấu hình squid.conf

Backup /etc/squid/squid.conf .

cp /etc/squid/squid.conf /etc/squid/squid.conf-backup

Tiến hành thay thế file trên bằng nội dung sau đây là file cấu hình Onet sử dụng.

http_port 3128
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
acl localnet src 10.0.0.0/22 # RFC 1918 possible internal network
acl localnet src 172.16.0.0/22 # RFC 1918 possible internal network
acl localnet src 192.168.0.0/22 # RFC 1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443 # https
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http

acl CONNECT method CONNECT
#http_access allow Safe_ports
#http_access allow CONNECT SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localnet
http_access allow localhost
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
http_access allow all

Bước 4  :Xác thực squid client authentication

yum -y install httpd-tools
touch /etc/squid/passwd 
chown squid: /etc/squid/passwd

Tiếp theo chúng ta cần tạo một user mới có tên blogdclient và đặt password cho nó:

htpasswd /etc/squid/passwd onetidc

Khởi động lại 1 lần nữa :

systemctl restart squid

Bước 5 : Block website với squid proxy

Chúng ta chỉ cần thêm tên miền vào file .

touch /etc/squid/blacklist_site.acl

Sau đó chúng ta thêm các domain cần block:

.test1.com
.test2.vn
.test3.net

Trong đó dấu chấm dầu tiên giúp chúng ta loại bỏ www, cũng như các subdomain của domain đó.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Backup và Restore Full hệ điều hành Linux Centos Ubuntu

LINUX BACKUP & RESTORE Mình viết bài này để hướng dẫn kỹ thuật backup và restore cả OS, bạn có...
25/12/2020

Tổng hợp file iso windows 7 windows 10 vultr siêu nhẹ bản gốc sạch – Windows Server 2016 , Windows Server 2019 Windows Server 2022 vultr

Link tải file iso tất cả các phiên bản ở :  https://tb.rg-adguard.net/public.php Hoặc Windows Server 2012...
28/12/2020

Hướng Dẫn kích hoạt bản quyền Active license Windows server 2019 mọi phiên bản không sử dụng file crack – không virus – thành công 100%

Active license Windows server 2019 mọi phiên bản không sử​​ dụng file crack – không virus – thành...
09/09/2021
Bài Viết

Bài Viết Mới Cập Nhật

Mua proxy v4 chạy socks5 để chơi game an toàn, tốc độ cao ở đâu?
18/05/2024

Thuê mua proxy Telegram trọn gói, tốc độ cao, giá siêu hời
18/05/2024

Thuê mua proxy Viettel ở đâu uy tín, chất lượng và giá tốt? 
14/05/2024

Dịch vụ thuê mua proxy US UK uy tín, chất lượng số #1
13/05/2024

Thuê mua proxy Việt Nam: Báo giá & các thông tin MỚI NHẤT
13/05/2024