Squid Web Cache Wiki

Squid Web Cache 文档

🔗 支持 HTTPS 虚拟主机和反向代理

🔗 用法

此配置示例介绍了当 Squid 作为“反向代理”(也称为 CDN 前端或网关代理)时,如何配置 Squid 代理来接收多个域的 HTTPS 流量。

此配置适用于使用 GnuTLS 支持构建的 Squid-4 及更新版本。较旧的 Squid 版本以及使用 OpenSSL 支持构建的 Squid 无法这样配置。

🔗 Squid 配置

https_port 443 accel defaultsite=example.net \
    tls-cert=/etc/squid/tls/example.net.pem \
    tls-cert=/etc/squid/tls/example.com.pem \
    tls-cert=/etc/squid/tls/example.org.pem

接下来,您需要告诉 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

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