CentOS 安装Squid代理

环境:

华为云服务器一台:123.60.53.69,放行3128端口

Windows 11 电脑:动态IP

需求:

客户端电脑通过华为云服务器实现代理上网

一、服务器设置

1、安装

复制代码
yum install squid httpd-tools -y

2、创建用户,生成密码文件

bash 复制代码
htpasswd -cd /etc/squid/passwd tom.ma

# 创建密码
New password: 
Re-type new password: 
Adding password for user tom.ma

3、检查是否存在验验文件

bash 复制代码
rpm -ql squid | grep ncsa_auth

# 输出
/usr/lib64/squid/basic_ncsa_auth
/usr/share/man/man8/basic_ncsa_auth.8.gz

4、编辑配置文件

bash 复制代码
vim /etc/squid/squid.conf


# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

#########新增的内容#########

# 使用帐号密码认证方式使用代理
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
# 定义用户的登录时显示的内容
auth_param basic realm This is a Squid Proxy Server
# 定义授权组
acl authenticated proxy_auth REQUIRED
# 允许授权组
http_access allow authenticated

# And finally deny all other access to this proxy
http_access deny all

5、启动

复制代码
systemctl start squid

二、客户端设置

1、windows11 设置代理

2、我们用Edge浏览器上网,此时我们输入账密验证

3、登录成功后,我们正确能打开网站

4、我们查看我们电脑的IP

相关推荐
切糕师学AI4 分钟前
ARM 中的 SVC 监管调用(Supervisor Call)
linux·c语言·汇编·arm开发
陌上花开缓缓归以7 分钟前
linux jiffies 初始化不为0问题分析
linux·arm开发
霖霖总总10 分钟前
[小技巧39]Linux 文件与命令查找工具(which、whereis、locate、find)全面解析
linux·运维
xlq2232213 分钟前
6.Linux权限
linux
ayaya_mana26 分钟前
在 CentOS 7/RHEL 7 上安装并切换至新版内核
linux·运维·centos
三不原则42 分钟前
故障案例:数据库慢查询导致交易延迟,AIOps 如何自动定位?
运维·数据库
gzxx2007sddx1 小时前
ubuntu挂载访问windows的共享文件夹
linux·运维·ubuntu·挂载·共享
市安1 小时前
基于 LVS+Keepalived+NFS 的高可用 Web 集群构建与验证
运维·服务器·网络·lvs·keepalived·ipvsadm
AC赳赳老秦1 小时前
Dify工作流+DeepSeek:运维自动化闭环(数据采集→报告生成)
android·大数据·运维·数据库·人工智能·golang·deepseek
真的想上岸啊1 小时前
4、修改开发板内核启动日志级别
linux