Tips Cài đặt proxy Squid trên máy chủ Linux để dùng riêng

TricksMMO

Administrator
Staff member
#squid #Proxy #linux #Server #caching

## Cách cài đặt Squid Proxy trên máy chủ Linux

Squid là máy chủ proxy miễn phí và nguồn mở, có thể được sử dụng để cải thiện hiệu suất duyệt web bằng cách lưu trữ các trang web được truy cập thường xuyên.Nó cũng có thể được sử dụng để hạn chế quyền truy cập vào các trang web nhất định hoặc để lọc nội dung.

Hướng dẫn này sẽ chỉ cho bạn cách cài đặt Squid trên máy chủ Linux.Chúng tôi sẽ sử dụng Ubuntu 20.04 cho hướng dẫn này, nhưng các bước phải tương tự cho các bản phân phối Linux khác.

### Điều kiện tiên quyết

Trước khi bạn có thể cài đặt SQUID, bạn sẽ cần phải có các điều kiện tiên quyết sau:

* Một máy chủ Linux có tối thiểu 1GB RAM và 20GB dung lượng đĩa.
* Cài đặt hoạt động của các gói sau:
* `apt-get`
* `dpkg`
* `iptables`
* `Net-tools`

### Cài đặt mực

Để cài đặt SQUID, hãy mở một cửa sổ đầu cuối và chạy lệnh sau:

`` `
SUDO apt-get install Squid
`` `

Điều này sẽ cài đặt phiên bản mới nhất của Squid trên máy chủ của bạn.

### Cấu hình mực

Khi Squid được cài đặt, bạn sẽ cần phải định cấu hình nó.Tệp cấu hình mực được đặt tại `/etc/squid/squid.conf`.

Sau đây là cấu hình mực cơ bản mà bạn có thể sử dụng làm điểm bắt đầu:

`` `
# Tệp cấu hình mực

# --------------------------------------------------------------------
# Cài đặt chung
# --------------------------------------------------------------------

# Địa chỉ nghe và cổng để Squid nghe.
http_port 3128

# Số lượng kết nối tối đa mà Squid sẽ chấp nhận.
Maximum_Connections 10000

# Số lượng yêu cầu tối đa mà một ứng dụng khách có thể thực hiện mỗi giây.
Maximum_Requests_per_second 100

# Lượng thời gian tối đa mà kết nối máy khách có thể không hoạt động trước khi đóng cửa.
Maximum_idle_time 300

# Lượng thời gian tối đa mà kết nối máy khách có thể được giữ mở cho một yêu cầu duy nhất.
Maximum_Connect_Time 60

# Lượng bộ nhớ tối đa mà Squid có thể sử dụng để lưu trữ.
Maximum_Memory 100000000

# Thư mục nơi Squid sẽ lưu trữ bộ đệm của nó.
bộ nhớ cache_dir/var/cache/squid 100000000 16 256

# --------------------------------------------------------------------
# Kiểm soát truy cập
# --------------------------------------------------------------------

# Danh sách kiểm soát truy cập mặc định.Điều này cho phép tất cả các khách hàng truy cập tất cả các trang web.
ACL tất cả SRC 0,0.0.0/0

# Bạn có thể tạo danh sách kiểm soát truy cập cụ thể hơn để hạn chế quyền truy cập vào một số trang web hoặc khách hàng nhất định.
# Ví dụ: ACL sau đây sẽ chỉ cho phép các máy khách từ mạng con 192.168.1.0/24 truy cập trang web www.example.com:
#
# ACL Localnet SRC 192.168.1.0/24
# http_access cho phép LocalNet www.example.com

# --------------------------------------------------------------------
# Ghi nhật ký
# --------------------------------------------------------------------

# Squid sẽ ghi lại tất cả các yêu cầu vào tệp /var/log/squid/access.log.
access_log /var/log/squid/access.log

# Bạn cũng có thể định cấu hình Squid để ghi nhật ký thông tin khác, chẳng hạn như lỗi và truy cập bộ đệm.
# Để biết thêm thông tin, xem tài liệu mực.

# --------------------------------------------------------------------
# Bộ nhớ đệm
# --------------------------------------------------------------------

# SQUID sẽ lưu trữ nội dung của các trang web mà nó truy xuất.Điều này có thể cải thiện hiệu suất duyệt web bằng cách giảm lượng thời gian cần thiết để tải các trang web.

# Bạn có thể định cấu hình Squid thành bộ đệm các loại nội dung khác nhau, chẳng hạn như hình ảnh, tệp HTML và tệp JavaScript.
# Để biết thêm thông tin, xem tài liệu mực.

`` `

Khi bạn đã cấu hình SQUID, bạn có thể bắt đầu bằng cách chạy lệnh sau:

`` `
SUDO Service Squid Start
`` `

Squid bây giờ sẽ chạy trên
=======================================
#squid #Proxy #linux #Server #caching

## How to Install Squid Proxy on a Linux Server

Squid is a free and open-source proxy server that can be used to improve the performance of web browsing by caching frequently accessed web pages. It can also be used to restrict access to certain websites or to filter content.

This tutorial will show you how to install Squid on a Linux server. We will be using Ubuntu 20.04 for this tutorial, but the steps should be similar for other Linux distributions.

### Prerequisites

Before you can install Squid, you will need to have the following prerequisites:

* A Linux server with a minimum of 1GB of RAM and 20GB of disk space.
* A working installation of the following packages:
* `apt-get`
* `dpkg`
* `iptables`
* `net-tools`

### Installing Squid

To install Squid, open a terminal window and run the following command:

```
sudo apt-get install squid
```

This will install the latest version of Squid on your server.

### Configuring Squid

Once Squid is installed, you will need to configure it. The Squid configuration file is located at `/etc/squid/squid.conf`.

The following is a basic Squid configuration that you can use as a starting point:

```
# Squid configuration file

# ----------------------------------------------------------------
# General settings
# ----------------------------------------------------------------

# The listen address and port for Squid to listen on.
http_port 3128

# The maximum number of connections that Squid will accept.
maximum_connections 10000

# The maximum number of requests that a single client can make per second.
maximum_requests_per_second 100

# The maximum amount of time that a client connection can be idle before it is closed.
maximum_idle_time 300

# The maximum amount of time that a client connection can be held open for a single request.
maximum_connect_time 60

# The maximum amount of memory that Squid can use for caching.
maximum_memory 100000000

# The directory where Squid will store its cache.
cache_dir /var/cache/squid 100000000 16 256

# ----------------------------------------------------------------
# Access control
# ----------------------------------------------------------------

# The default access control list. This allows all clients to access all websites.
acl all src 0.0.0.0/0

# You can create more specific access control lists to restrict access to certain websites or clients.
# For example, the following ACL would allow only clients from the 192.168.1.0/24 subnet to access the website www.example.com:
#
# acl localnet src 192.168.1.0/24
# http_access allow localnet www.example.com

# ----------------------------------------------------------------
# Logging
# ----------------------------------------------------------------

# Squid will log all requests to the /var/log/squid/access.log file.
access_log /var/log/squid/access.log

# You can also configure Squid to log other information, such as errors and cache hits.
# For more information, see the Squid documentation.

# ----------------------------------------------------------------
# Caching
# ----------------------------------------------------------------

# Squid will cache the contents of web pages that it retrieves. This can improve the performance of web browsing by reducing the amount of time that it takes to load web pages.

# You can configure Squid to cache different types of content, such as images, HTML files, and JavaScript files.
# For more information, see the Squid documentation.

```

Once you have configured Squid, you can start it by running the following command:

```
sudo service squid start
```

Squid will now be running on
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top