ALADOWN-阿拉下载 - 2023年11月6日
type: channel
link: https://www.aladown.com/2023/11/06/
description: WE'RE COME BACK!!
items: 如何配实现Squid多开实例同时运行？

如何配实现Squid多开实例同时运行？
type: item
date: 2023-11-06T01:09:19-05:00
description: 准备实例的配置文件以及服务控制脚本 ```csharp cp /etc/squid/squid.conf /etc/squid/squid-dg.conf cp /etc/squid/squid.conf /etc/squid/squid-hk.conf cp /lib/systemd/system/squid.service /lib/systemd/system/squid-dg.service cp /lib/systemd/system/squid.service /lib/systemd/system/squid-hk.service ``` 修改实例配置 ```csharp nano /etc/squid/squid-dg.conf ``` dg简单的配置 ```csharp http_port 3129 pid_filename /run/squid-dg.pid access_log /var/log/squid/access-dg.log cache_log /var/log/squid/cache-dg.log ``` ```csharp nano /etc/squid/squid-hk.conf ``` hk简单的配置 ```csharp http_port 3129 pid_filename /run/squid-hk.pid access_log /var/log/squid/access-hk.log cache_log /var/log/squid/cache-hk.log ``` 复杂版的配置内容 ```csharp # =================================== MODE ==== # http proxy 监听端口， Server 的 Connect To 选项指向此端口 http_port 127.0.0.1:3128 #如果从远端过来的代理，这里就需要监控外网IP和端口 #http_port 8.8.8.8:3128 # =================================== ACCESS CONTROL ==== # 接受所有 http 请求（来自 127.0.0.1） http_access allow all #远端允许访问Squid的IP地址，多个IP用空格间隔 #acl myacl src 1.1.1.1 2.2.2.2 #http_access allow myacl # =================================== CONNECTION ==== connect_timeout 30 seconds # 连接超时 visible_hostname squid_FP_1 # 当前节点本机名称 client_persistent_connections on # 启用 client squid 之间的长连接支持 client_idle_pconn_timeout 180 minutes #client squid 之间的长连接空闲超时 half_closed_clients on # 允许 TCP 四次挥手过程中的半双工状态 server_persistent_connections on # 启用 squid server 之间的长连接支持 server_idle_pconn_timeout 180 minute # squid server 之间的长连接空闲超时 forwarded_for transparent # 不添加、不修改也不删除 X-Forwarded-For 头（默认添加） cache deny all # squid 3.x 不能正确缓存 gzip+chuncked 内容 # =================================== LOG FILE ==== pid_filename /run/squid-dg.pid access_log none #access_log daemon:/var/log/squid/access.log squid cache_store_log none ``` 修改实例服务控制脚本 ```csharp nano /lib/systemd/system/squid-dg.service ``` dg配置内容 ```csharp ## Copyright (C) 1996-2022 The Squid Software Foundation and contributors ## ## Squid software is distributed under GPLv2+ license and includes ## contributi…