安装Squid代理
安装squid 代理所需的软件包,使squid 服务在启动时自动启动。
# yum install squid # systemctl enable squid # systemctl start squid
如果我们没有最新的 openssl 版本,我们可能会收到以下错误
Job for squid.service failed because the control process exited with error code. See "systemctl status squid.service" and "journalctl -xe" for details.
为了确保,使用以下命令更新 openssl 版本:
# yum update openssl
现在我们可以继续启动quid服务。
# systemctl start squid
https://onitroad.com 更多教程
配置Squid代理
squid 代理默认监听 3128 端口。
我们可以更改此端口,因为它可能是某些的安全预防措施。
如果要更改此端口,请编辑 squid 配置文件 /etc/squid/squid.conf 修改端口 3128 的 http_port 指令。
我将保持端口相同,因为这是一个测试设置。
# vim /etc/squid/squid.conf # Squid normally listens to port 3128 http_port 3128
重新启动Squid服务以使更改生效。
# systemctl restart squid
验证Squid代理进程是否已启动。
# ps -ef | grep squid root 5403 1 0 03:21 ? 00:00:00 /usr/sbin/squid -f /etc/squid/squid.conf squid 5405 5403 0 03:21 ? 00:00:00 (squid-1) -f /etc/squid/squid.conf squid 5406 5405 0 03:21 ? 00:00:00 (logfile-daemon) /var/log/squid/access.log root 5448 5158 0 03:24 pts/0 00:00:00 grep --color=auto squid
我们还可以验证 squid 代理是否正在侦听端口 3128.
# ss -nlp | grep squid | grep 3128 tcp LISTEN 0 128 :::3128 :::* users:(("squid",pid=5405,fd=11))
我们还需要在 firewalld 中允许端口 3128,以防它被启用。
或者我们可以简单地完全禁用 firewalld。
# firewall-cmd --add-port=3128/tcp --permanent
设置客户端服务器以使用Squid
# export http_proxy=http://${PROXY_FQDN}:8080
在远程服务器上,为了验证我们可以连接到代理,我们可以运行 curl 到 google.com
# curl -v http://google.com | head -1 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* About to connect() to google.com port 80 (#0) * Trying 2607:f8b0:4009:804::200e... * Connected to google.com (2607:f8b0:4009:804::200e) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.29.0 > Host: google.com > Accept: */* > < HTTP/1.1 301 Moved Permanently < Location: http://www.google.com/ < Content-Type: text/html; charset=UTF-8 < Date: Wed, 05 Jun 2019 07:28:26 GMT < Expires: Fri, 05 Jan 2019 07:28:26 GMT < Cache-Control: public, max-age=2592000 < Server: gws < Content-Length: 219 < X-XSS-Protection: 0 < X-Frame-Options: SAMEORoirN < { [data not shown] 100 219 100 219 0 0 3145 0 --:--:-- --:--:-- --:--:-- 3173 * Connection #0 to host google.com left intact
Squid 是一个具有多种配置和用途的 Web 代理应用程序。
Squid 拥有大量的访问控制,并支持不同的协议,例如 HTTP、HTTPS、FTP 和 SSL。
在这篇文章中,我们将看到如何使用 Squid 作为 HTTP 代理。
搭建Squid代理
Squid 是一个相当古老、成熟且常用的软件。
它通常作为各种 Linux 发行版的默认包提供。
这篇文章的设置:
192.168.10.2 - is our proxy server. 192.168.10.3 - Will redirect/cache traffic via the proxy server.
日期:2020-09-17 00:12:39 来源:oir作者:oir