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

相关推荐
小涵7 分钟前
第 01 天:Linux 是什么?内核、发行版及其生态系统
linux·运维·devops·1024程序员节·sre
小小的木头人21 分钟前
APT 安装方式(适合生产环境)Zabbix 6.4 LTS
运维·zabbix
IvanCodes22 分钟前
十六、Linux网络配置
linux·运维·网络
j_xxx404_24 分钟前
Linux:权限(完结)|权限管理|修改权限chmod chown charp|文件类型|拓展
linux·运维·服务器
板鸭〈小号〉43 分钟前
应用层自定义协议与序列化
运维·服务器·网络·1024程序员节
报错小能手1 小时前
项目——基于C/S架构的预约系统平台(2)
linux·c语言·笔记·学习·架构
Wang's Blog1 小时前
Linux小课堂: CentOS 7 Minimal 服务器安装与网络配置实战详解
linux·服务器·centos
go_bai2 小时前
Linux_基础IO(2)
linux·开发语言·经验分享·笔记·学习方法·1024程序员节
Test-Sunny2 小时前
MLOps 的CI/CD VS DevOps 的CI/CD
运维·ci/cd·devops
YongCheng_Liang2 小时前
Windows CMD 常用命令:7 大核心模块速查指南(附实战场景)
运维·服务器·windows·1024程序员节