3.4. 在 Squid 中配置域拒绝列表

通常,管理员想要阻止对特定域的访问。这部分论述了如何在 Squid 中配置域拒绝列表。

先决条件

  • squid 被配置,用户可以使用代理。

流程

  1. 编辑 /etc/squid/squid.conf 文件,并添加以下设置:

    acl domain_deny_list dstdomain "/etc/squid/domain_deny_list.txt"
    http_access deny all domain_deny_list
    重要

    在允许访问用户或客户端的第一个 http_access allow 语句前添加这些条目。

  2. 创建 /etc/squid/domain_deny_list.txt 文件,并添加您要阻止的域。例如,要阻止对 example.com(包括子域)以及对 example.net 的访问,请添加:

    .example.com
    example.net
    重要

    如果您引用了 squid 配置中的 /etc/squid/domain_deny_list.txt 文件,则该文件不能为空。如果文件为空,Squid 无法启动。

  3. 重启 squid 服务:

    # systemctl restart squid