如何在 Debian 11 上安装 Squid 代理
admin
2023-07-31 03:20:56
0

Squid 是最常用的代理服务器之一,用于控制来自本地网络的 Internet 访问并保护网络免受非法访问流量和攻击。Squid 还通过缓存和重用频繁请求的网页来减少带宽并提高响应时间。Squid 具有广泛的访问控制功能,是出色的服务器加速器。Squid-cacheSquid-cache

在 Debian 11 Bullseye 上安装 Squid 代理

apt步骤 1. 在我们安装任何软件之前,通过在终端中运行以下命令来确保您的系统是最新的,这一点很重要:

sudo apt update
sudo apt upgrade

步骤 2. 在 Debian 11 上安装 Squid 代理。

默认情况下,Squid 代理在 Debian 11 基础存储库中不可用。因此,现在运行以下命令将 Squid Proxy 安装到您的系统:

sudo apt install squid

安装完成后,代理将自动启动。要验证其功能是否正确,请运行以下命令:

sudo systemctl status squid

步骤 3. 在 Debian 11 上配置 Squid 代理。

首先,我们创建 Squid 可以用来验证用户身份验证的身份验证文件:

htpasswd -b /etc/squid/squid_passwd [username] [password]

例如,创建 Squid 身份验证:

htpasswd -b -c /etc/squid/squid_passwd meilana maria

现在转到位于以下位置的 Squid 代理服务器的主配置文件:/etc/squid/squid.conf

sudo nano /etc/squid/squid.conf

添加以下配置:

sudo nano /etc/squid/squid.conf
# Recommended minimum configuration:
auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid/squid_passwd
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users

acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
acl SSL_ports port 443
acl Safe_ports port 80            # http
acl Safe_ports port 21            # ftp
acl Safe_ports port 443           # https
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 SSL_ports port 9001           # webmin
acl CONNECT method CONNECT

http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny all
http_port 3128 # Squid normally listens to port 3128

forwarded_for off

request_header_access Allow allow all
request_header_access Authorization 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
visible_hostname idroot.us

保存并关闭文件,然后重新启动 squid 代理服务器以应用更改:

sudo systemctl restart squid

步骤 4. 配置防火墙。

默认情况下,在 Debian 上启用了 UFW 防火墙。根据您的 Squid 配置文件,打开端口 3128 以允许 HTTP 流量:

ufw allow 3128/tcp
sudo ufw reload

步骤 5. 为 Squid 代理服务器配置客户端。

让我们用 Firefox Web 浏览器做一个简单的代理测试,将其配置为通过您的 Squid 服务器连接外部网络。.Preferences -> General -> Network Settings -> Manual Proxy Configuration

squid-proxy-configure-browsersquid-proxy-configure-browser

感谢您使用本教程在 Debian 11 Bullseye 上安装最新版本的 Squid 代理。如需更多帮助或有用信息,我们建议您查看Squid 官方网站。

相关内容

热门资讯

Windows 11 和 10... Windows 11/10 文件夹属性中缺少共享选项卡 – 已修复 1.检查共享选项卡是否可用 右键...
Radmin VPN Wind... Radmin VPN 是一款免费且用户友好的软件,旨在牢固地连接计算机以创建一个有凝聚力的虚拟专用网...
如何修复 Steam 内容文件... Steam 内容文件锁定是当您的 Steam 文件无法自行更新时出现的错误。解决此问题的最有效方法之...
在 Windows 11 中打... 什么是链路状态电源管理? 您可以在系统控制面板的电源选项中看到链接状态电源管理。它是 PCI Exp...
iPhone 屏幕上有亮绿色斑... iPhone 是市场上最稳定的智能手机之一,这主要归功于专为它们设计的 iOS 操作系统。然而,他们...
事件 ID 7034:如何通过... 点击进入:ChatGPT工具插件导航大全 服务控制管理器 (SCM) 负责管理系统上运行的服务的活动...
QQ浏览器怎么制作简历 QQ浏览器是腾讯公司开发的一款极速浏览器,支持电脑,安卓,苹果等多种终端;更快的浏览体验,更安全的浏...
Hive OS LOLMine... 目前不清退的交易所推荐: 1、全球第二大交易所OKX欧意 国区邀请链接: https://www.m...
Apple Watch Ult... 所有运行 watchOS 7 或更高版本的 Apple Watch 型号都包含一项名为“优化电池充电...
统信UOS每次开机后不直接进入... 统信UOS每次开机后不直接进入系统而是进入到recovery模式 按方向上键选择UOS 20 SP1...