Squid Web Cache Wiki

Squid Web Cache 文档

🔗 配置基本反向代理(网站加速器)

🔗 目录

此配置涵盖了基本反向代理(加速器)的配置。更高级的配置都建立在这些基本设置之上。

有关反向代理和HTTP加速是什么的详细概述,请参阅FAQ 反向代理页面。

:information_source: http_port 的 accel 选项应仅为 2.6.STABLE8 及更高版本指定。

🔗 Squid 配置文件

:warning: 此配置必须出现在 squid.conf 的顶部,位于任何其他正向代理配置(http_access 等)之前。否则,标准的代理访问规则会阻止一些用户访问加速后的网站。

首先,您必须告诉 Squid 监听端口 80(通常),因此设置 http_port 选项,并使用 defaultsite 选项告诉 Squid 这是该网站的加速器

http_port 80 accel defaultsite=your.main.website.name no-vhost

接下来,您需要告诉 Squid 在哪里可以找到真实的 Web 服务器

cache_peer backend.webserver.ip.or.dnsname parent 80 0 no-query originserver name=myAccel

最后,您需要设置访问控制,以允许访问您的网站,而不会将其他 Web 请求推送到您的 Web 服务器。

acl our_sites dstdomain your.main.website.name
http_access allow our_sites
cache_peer_access myAccel allow our_sites
cache_peer_access myAccel deny all

您现在应该能够启动 Squid,它将作为 HTTP 服务器提供请求。

🔗 测试和上线

反向代理的测试应在 Squid 配置正确、符合生产环境使用的情况下进行,但公共 DNS 设置不应指向它。可以通过修改测试机的 /etc/hosts 文件,将测试请求发送到 squid IP 而不是实际的 Web 服务器。

当测试成功后,可以更新公共 DNS,将公共请求发送到 Squid 代理而不是主 Web 服务器,加速将立即开始。


⚠️ Disclaimer: Any example presented here is provided "as-is" with no support
or guarantee of suitability. If you have any further questions about
these examples please email the squid-users mailing list.

类别: ConfigExample

导航:网站搜索网站页面分类🔼 向上