温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Ubuntu怎么安装squid并启用SSL

发布时间:2022-11-25 10:13:51 来源:亿速云 阅读:208 作者:iii 栏目:服务器

这篇文章主要介绍“Ubuntu怎么安装squid并启用SSL”,在日常操作中,相信很多人在Ubuntu怎么安装squid并启用SSL问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Ubuntu怎么安装squid并启用SSL”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

安装openssl

首先需要安装 openssl 及相关的依赖。

apt-getinstallopenssl
apt-getinstalllibssl-dev
apt-getinstallssl-cert

安装squid

直接使用 apt 安装的 squid 没有启用 SSL,所以需要使用源代码编译安装。

apt-getsourcesquid
apt-getbuild-depsquid
apt-getinstalldevscriptsbuild-essentialfakeroot

#squid版本为3.3.8
cdsquid3-3.3.8

#修改编译参数
vimdebian/rules

#在DEB_CONFIGURE_EXTRA_FLAGS配置中添加
#注意with-open-ssl的值为实际openssl.cnf所在路径
--enable-ssl\
--with-open-ssl=/usr/lib/ssl/openssl.cnf\

#编译squid
./configure
debuild-us-uc-b

#安装
cd..
apt-getinstallsquid-langpack
dpkg-isquid3-common_3.3.8-1ubuntu6.2_all.deb
dpkg-isquid3_3.3.8-1ubuntu6.2_amd64.deb

生成 SSL 证书

配置 squid

将配置文件修改成如下内容。我这里没有启用身份验证,如果需要可以自行添加。squid 端口号修改为 9999,也可以按需修改。

aclSSL_portsport443
aclSafe_portsport80#http
aclSafe_portsport21#ftp
aclSafe_portsport443#https
aclSafe_portsport70#gopher
aclSafe_portsport210#wais
aclSafe_portsport1025-65535#unregisteredports
aclSafe_portsport280#http-mgmt
aclSafe_portsport488#gss-http
aclSafe_portsport591#filemaker
aclSafe_portsport777#multilinghttp
aclCONNECTmethodCONNECT

http_accessdeny!Safe_ports

http_accessdenyCONNECT!SSL_ports
http_accessallowlocalhostmanager
http_accessdenymanager
http_accessallowlocalhost
http_accessallowall

#修改为证书路径
https_port9999cert=/ssl/ssl.crtkey=/ssl/ssl.private.key

coredump_dir/var/spool/squid3

refresh_pattern^ftp:144020%10080
refresh_pattern^gopher:14400%1440
refresh_pattern-i(/cgi-bin/|\?)00%0
refresh_pattern(Release|Packages(.gz)*)$020%2880
refresh_pattern.020%4320

viaoff
forwarded_fordelete
dns_v4_firston

需要注意的是,ssl.private.key是证书的私钥,不需要密码保护,不然 squid 无法启动。可以使用下列命令生成无密码保护的私钥:

opensslrsa-inssl.key-outssl.private.key

配置防火墙

我使用的是 ufw,所以运行

ufwallow9999

重启 squid 就可以正常使用了。

禁用 squid 升级

由于我们是使用源代码编译的 squid,所以升级会破坏配置,需要禁用 squid 升级。

sudoapt-markholdsquid3

到此,关于“Ubuntu怎么安装squid并启用SSL”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI