统信UOS搭建Squid代理服务器(1),BATJ等企业Linux运维面试知识分享

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Linux运维全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上运维知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip1024b (备注运维)
img

正文


![image.png](https://img-blog.csdnimg.cn/img_convert/b2c8f80003bd14ecff7197b9e83ef805.png)


4.安装Apache工具(包含htpasswd)  
 htpasswd是Apache服务器的一部分,用于创建和更新经过哈希处理的密码文件。



[root@pdsyw ~]# yum install httpd-tools -y
Last metadata expiration check: 0:41:09 ago on 2024年01月04日 星期四 19时24分51秒.
Dependencies resolved.

Package Arch Version Repository Size

Installing:
httpd-tools x86_64 2.4.43-23.up1.uel20
UnionTechOS-Server-20-everything 68 k
Installing dependencies:
apr x86_64 1.7.0-5.uel20 UnionTechOS-Server-20-everything 108 k
apr-util x86_64 1.6.1-15.uel20 UnionTechOS-Server-20-everything 108 k

Transaction Summary

Install 3 Packages

Total download size: 284 k
Installed size: 763 k
Downloading Packages:
(1/3): apr-1.7.0-5.uel20.x86_64.rpm 465 kB/s | 108 kB 00:00
(2/3): apr-util-1.6.1-15.uel20.x86_64.rpm 427 kB/s | 108 kB 00:00
(3/3): httpd-tools-2.4.43-23.up1.uel20.x8 238 kB/s | 68 kB 00:00

Total 973 kB/s | 284 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: apr-1.7.0-5.uel20.x86_64 1/3
Installing : apr-1.7.0-5.uel20.x86_64 1/3
Running scriptlet: apr-1.7.0-5.uel20.x86_64 1/3
Running scriptlet: apr-util-1.6.1-15.uel20.x86_64 2/3
Installing : apr-util-1.6.1-15.uel20.x86_64 2/3
Running scriptlet: apr-util-1.6.1-15.uel20.x86_64 2/3
Installing : httpd-tools-2.4.43-23.up1.uel20.x86_64 3/3
Running scriptlet: httpd-tools-2.4.43-23.up1.uel20.x86_64 3/3
Verifying : apr-1.7.0-5.uel20.x86_64 1/3
Verifying : apr-util-1.6.1-15.uel20.x86_64 2/3
Verifying : httpd-tools-2.4.43-23.up1.uel20.x86_64 3/3

Installed:
apr-1.7.0-5.uel20.x86_64 apr-util-1.6.1-15.uel20.x86_64
httpd-tools-2.4.43-23.up1.uel20.x86_64

Complete!
[root@pdsyw ~]#


![image.png](https://img-blog.csdnimg.cn/img_convert/5a62cf0e4de849840da9c78396b9e44f.png)


5.创建密码文件  
 使用htpasswd来创建一个新的密码文件。此文件将存储经过验证的用户名和密码。  
 这里,pdsyw是你希望创建的第一个用户名。系统会提示你输入密码。-c参数用于首次创建新文件,如果你想要添加更多用户,再次运行命令但省略-c参数。



[root@pdsyw ~]# htpasswd -c /etc/squid/passwords pdsyw
New password:
Re-type new password:
Adding password for user pdsyw
[root@pdsyw ~]#
[root@pdsyw ~]# htpasswd /etc/squid/passwords pdsywer
New password:
Re-type new password:
Adding password for user pdsywer
[root@pdsyw ~]#


![image.png](https://img-blog.csdnimg.cn/img_convert/75edff7e0a0c23f34ac8685410f5c60c.png)


6.调整文件权限  
 确保Squid进程能够读取密码文件



[root@pdsyw ~]# chmod o+r /etc/squid/passwords
[root@pdsyw ~]#
[root@pdsyw ~]# ll /etc/squid/passwords
-rw-r–r-- 1 root root 90 1月 4 20:07 /etc/squid/passwords
[root@pdsyw ~]#


![image.png](https://img-blog.csdnimg.cn/img_convert/eb83798941a7c47e8800c23a7f56b366.png)


7.验证配置  
 这个命令将检查配置文件语法是否有误。确保没有错误再继续。



http_port 172.16.0.2:3128:Squid将监听在内网地址172.16.0.2的3128端口上。
acl localnet src 172.16.0.0/24:定义了一个名为localnet的访问控制列表(ACL),包含IP范围172.16.0.0/24,即你的公司内网。
http_access allow localnet:允许localnet定义的内网访问Squid代理。
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwords:配置了基本认证,使用/usr/lib64/squid/basic_ncsa_auth程序和密码文件/etc/squid/passwords。
auth_param basic realm proxy:定义了在认证提示中显示的领域(realm)名称为proxy。
acl authenticated proxy_auth REQUIRED:定义了一个名为authenticated的ACL,要求必须通过代理认证。
http_access allow authenticated:允许通过认证的用户访问代理。
http_access deny all:默认拒绝所有其他访问。
cache_dir ufs /var/spool/squid 10000 16 256:配置了Squid的缓存目录和参数。
access_log /var/log/squid/access.log squid:定义了Squid的访问日志文件路径。



[root@pdsyw ~]# squid -k parse
2024/01/04 20:16:31| Startup: Initializing Authentication Schemes …
2024/01/04 20:16:31| Startup: Initialized Authentication Scheme ‘basic’
2024/01/04 20:16:31| Startup: Initialized Authentication Scheme ‘digest’
2024/01/04 20:16:31| Startup: Initialized Authentication Scheme ‘negotiate’
2024/01/04 20:16:31| Startup: Initialized Authentication Scheme ‘ntlm’
2024/01/04 20:16:31| Startup: Initialized Authentication.
2024/01/04 20:16:31| Processing Configuration File: /etc/squid/squid.conf (depth 0)
2024/01/04 20:16:31| Processing: http_port 172.16.0.2:3128
2024/01/04 20:16:31| Processing: acl localnet src 172.16.0.0/24 # 你的公司内网IP段
2024/01/04 20:16:31| Processing: auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwords
2024/01/04 20:16:31| Processing: auth_param basic realm proxy
2024/01/04 20:16:31| Processing: acl authenticated proxy_auth REQUIRED
2024/01/04 20:16:31| Processing: http_access allow authenticated
2024/01/04 20:16:31| Processing: http_access allow localne
2024/01/04 20:16:31| Processing: http_access deny all
2024/01/04 20:16:31| Processing: cache_dir ufs /var/spool/squid 10000 16 256
2024/01/04 20:16:31| Processing: access_log /var/log/squid/access.log squid
2024/01/04 20:16:31| Initializing https:// proxy context


![image.png](https://img-blog.csdnimg.cn/img_convert/737d2f3178cabeaee57d257c3faccab3.png)


8.启动服务  
 应用配置更改并重新启动Squid服务,确保Squid服务正在正常运行。



[root@pdsyw ~]# systemctl restart squid
[root@pdsyw ~]#
[root@pdsyw ~]# systemctl status squid
● squid.service - Squid caching proxy
Loaded: loaded (/usr/lib/systemd/system/squid.service; disabled; vendo>
Active: active (running) since Thu 2024-01-04 19:35:48 CST; 4s ago
Process: 27751 ExecStartPre=/usr/libexec/squid/cache_swap.sh (code=exit>
Process: 27757 ExecStart=/usr/sbin/squid $SQUID_OPTS -f $SQUID_CONF (co>
Main PID: 27758 (squid)
Tasks: 3
Memory: 12.5M
CGroup: /system.slice/squid.service
├─27758 /usr/sbin/squid -f /etc/squid/squid.conf
├─27760 (squid-1) --kid squid-1 -f /etc/squid/squid.conf
└─27763 (logfile-daemon) /var/log/squid/access.log

1月 04 19:35:48 pdsyw systemd[1]: Starting Squid caching proxy…
1月 04 19:35:48 pdsyw systemd[1]: Started Squid caching proxy.
1月 04 19:35:48 pdsyw squid[27758]: Squid Parent: will start 1 kids
1月 04 19:35:48 pdsyw squid[27758]: Squid Parent: (squid-1) process 27760>
[root@pdsyw ~]#


![image.png](https://img-blog.csdnimg.cn/img_convert/f198d6e5e073c50bcfbe0979e3729321.png)


9.放开防火墙  
 放开Squid默认端口(3128)



[root@pdsyw ~]# firewall-cmd --permanent --add-port=3128/tcp
success
[root@pdsyw ~]#
[root@pdsyw ~]# firewall-cmd --reload
success
[root@pdsyw ~]#


![image.png](https://img-blog.csdnimg.cn/img_convert/9bbced152b3ed1972b193ae290dd3e0e.png)


10.客户端信息  
 1)查看终端信息



pdsyw@pdsyw-PC:~/Desktop$ cat /etc/os-version
[Version]
SystemName=UOS Desktop
SystemName[zh_CN]=统信桌面操作系统
ProductType=Desktop
ProductType[zh_CN]=桌面
EditionName=Professional
EditionName[zh_CN]=专业版
MajorVersion=20
MinorVersion=1060
OsBuild=11018.100.100
pdsyw@pdsyw-PC:~/Desktop$
pdsyw@pdsyw-PC:~/Desktop$ uname -a
Linux pdsyw-PC 4.19.0-amd64-desktop #6030 SMP Tue Jun 27 15:58:51 CST 2023 x86_64 GNU/Linux
pdsyw@pdsyw-PC:~/Desktop$


![image.png](https://img-blog.csdnimg.cn/img_convert/cdae147813a95e3110f1ea4e8cc15ff8.png)


2)查看终端ip地址



pdsyw@pdsyw-PC:~/Desktop$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:29:ba:83 brd ff:ff:ff:ff:ff:ff
3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:29:ba:8d brd ff:ff:ff:ff:ff:ff
inet 172.16.0.133/24 brd 172.16.0.255 scope global noprefixroute ens36
valid_lft forever preferred_lft forever
inet6 fe80::e77b:37eb:fab4:34a0/64 scope link noprefixroute
valid_lft forever preferred_lft forever
pdsyw@pdsyw-PC:~/Desktop$


![image.png](https://img-blog.csdnimg.cn/img_convert/a5703b7222a1bf03f01eff2fb5a53ee6.png)


11.通过配置应用代理的方式验证代理服务  
 11.1.首先验证当终端不配置应用代理时访问网页  
 a)不配置应用代理  
 ![image.png](https://img-blog.csdnimg.cn/img_convert/be504bed551e4633424e6ec706e8f2e3.png)


b)打开浏览器  
 [外链图片转存中…(img-MUQ2trGR-1704701260444)]


c)访问网页失败  
 ![image.png](https://img-blog.csdnimg.cn/img_convert/1d98d19eaed1ca385cf20b85d36cf393.png)


11.2.验证当终端配置应用代理但不配置用户名密码时访问网页  
 a)配置应用代理但不配置用户名密码  
 ![image.png](https://img-blog.csdnimg.cn/img_convert/59d422775c41be852975394197ec5770.png)


b)点击使用代理,打开浏览器  
 ![image.png](https://img-blog.csdnimg.cn/img_convert/75d73f1c7e22a4be44d3b2f02abf1d87.png)


c)访问网页失败  
 ![image.png](https://img-blog.csdnimg.cn/img_convert/1d98d19eaed1ca385cf20b85d36cf393.png)


11.3.验证当终端配置应用代理且配置用户名密码时访问网页  
 a)配置应用代理且配置用户名密码  
 ![image.png](https://img-blog.csdnimg.cn/img_convert/fd357aa60fa39f6d8c51da85dcd21963.png)


b)点击使用代理,打开浏览器  
 ![image.png](https://img-blog.csdnimg.cn/img_convert/62aebeb6b3f7042558e6249a49fc8ed0.png)


c)访问网页成功  
 ![image.png](https://img-blog.csdnimg.cn/img_convert/e63e145a0a12ddbb856949f75b0727e5.png)


12.通过配置系统代理的方式验证代理服务  
 12.1.首先验证当终端不配置系统代理时访问网页  
 a)不配置系统代理  
 ![image.png](https://img-blog.csdnimg.cn/img_convert/cd51fd8cd97f347ea49aa87ba235a53b.png)


b)无法访问网页  
 ![image.png](https://img-blog.csdnimg.cn/img_convert/1d98d19eaed1ca385cf20b85d36cf393.png)

![](https://img-blog.csdnimg.cn/img_convert/9a8cb5f8c0ec69e6499adead0da6e95b.png)



最全的Linux教程,Linux从入门到精通

======================

1.  **linux从入门到精通(第2版)**

2.  **Linux系统移植**

3.  **Linux驱动开发入门与实战**

4.  **LINUX 系统移植 第2版**

5.  **Linux开源网络全栈详解 从DPDK到OpenFlow**



![华为18级工程师呕心沥血撰写3000页Linux学习笔记教程](https://img-blog.csdnimg.cn/img_convert/59742364bb1338737fe2d315a9e2ec54.png)



第一份《Linux从入门到精通》466页

====================

内容简介

====

本书是获得了很多读者好评的Linux经典畅销书**《Linux从入门到精通》的第2版**。本书第1版出版后曾经多次印刷,并被51CTO读书频道评为“最受读者喜爱的原创IT技术图书奖”。本书第﹖版以最新的Ubuntu 12.04为版本,循序渐进地向读者介绍了Linux 的基础应用、系统管理、网络应用、娱乐和办公、程序开发、服务器配置、系统安全等。本书附带1张光盘,内容为本书配套多媒体教学视频。另外,本书还为读者提供了大量的Linux学习资料和Ubuntu安装镜像文件,供读者免费下载。



![华为18级工程师呕心沥血撰写3000页Linux学习笔记教程](https://img-blog.csdnimg.cn/img_convert/9d4aefb6a92edea27b825e59aa1f2c54.png)



**本书适合广大Linux初中级用户、开源软件爱好者和大专院校的学生阅读,同时也非常适合准备从事Linux平台开发的各类人员。**

> 需要《Linux入门到精通》、《linux系统移植》、《Linux驱动开发入门实战》、《Linux开源网络全栈》电子书籍及教程的工程师朋友们劳烦您转发+评论




**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注运维)**
![img](https://img-blog.csdnimg.cn/img_convert/4b015a39b2232027d7fad97ed12c943a.jpeg)

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**
的学生阅读,同时也非常适合准备从事Linux平台开发的各类人员。**

> 需要《Linux入门到精通》、《linux系统移植》、《Linux驱动开发入门实战》、《Linux开源网络全栈》电子书籍及教程的工程师朋友们劳烦您转发+评论




**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注运维)**
[外链图片转存中...(img-Vbf4uNC9-1713265886352)]

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**
  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值