代理服务器的 Squid 配置

代理服务器的 Squid 配置

可能重复:
代理服务器的 Squid 配置

我有一台具有 10 个 IP 的服务器,我想通过身份验证授予一些朋友访问权限,但我被困在 squid 的配置文件中。

假设我的服务器上有以下可用的 IP:

212.77.23.10
212.77.1.10
68.44.82.112

我想将它们分别分配给不同的用户,如下所示:

212.77.23.10 goes to user manilodisan using password 123456
212.77.1.10 goes to user manilodisan1 using password 123456
68.44.82.112 goes to user manilodisan2 using password 123456

我设法添加了密码并且身份验证工作正常,但我该如何将一个用户限制在其中一个可用的 IP 上?

我根据从互联网上找到的不同资料建立了一个基本设置,但似乎没有什么用。这是我的 squid.conf(删除了所有注释以使其更简洁):

acl ip1 myip 212.77.23.10
acl ip2 myip 212.77.1.10
tcp_outgoing_address 212.77.23.10 ip1
tcp_outgoing_address 212.77.1.10 ip2
http_port 8888
visible_hostname weezie

auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid-passwd
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users 

acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443  # https
acl SSL_ports port 563  # snews
acl SSL_ports port 873  # rsync
acl Safe_ports port 80  # http
acl Safe_ports port 21  # ftp
acl Safe_ports port 443  # https
acl Safe_ports port 70  # gopher
acl Safe_ports port 210  # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280  # http-mgmt
acl Safe_ports port 488  # gss-http
acl Safe_ports port 591  # filemaker
acl Safe_ports port 777  # multiling http
acl Safe_ports port 631  # cups
acl Safe_ports port 873  # rsync
acl Safe_ports port 901  # SWAT
acl purge method PURGE
acl CONNECT method CONNECT

http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access deny all
icp_access allow all
hierarchy_stoplist cgi-bin ?
access_log /var/log/squid/access.log squid
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY

refresh_pattern ^ftp:  1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern .  0 20% 4320

acl apache rep_header Server ^Apache
broken_vary_encoding allow apache

extension_methods REPORT MERGE MKACTIVITY CHECKOUT

hosts_file /etc/hosts

forwarded_for off

coredump_dir /var/spool/squid

答案1

为什么不直接允许通过 IP 访问你的 squid 服务器?

如果您有 webmin,您可以尝试以下操作:

(本教程假设您已在服务器上成功安装了 Webmin 和 Squid)。列出这里

登录 Webmin 后,您将在左侧看到“服务器”。单击该服务器,然后单击“Squid 代理服务器”。您可能需要填写一些信息,例如 Squid 安装的正确路径。完成这些操作后,您将能够通过 Webmin 配置 Squid。

单击“端口和网络”,并记下 Squid 将使用的端口(默认值:3128)。这是您需要在浏览器中输入才能使用 Squid 的端口。然后返回 Squid 模块索引并单击“访问控制”按钮。

底部有一个名为“创建新 ACL”的按钮。单击该按钮之前,请从按钮旁边的下拉框中选择“客户端地址”。现在单击该按钮。在此页面上,您将填写以下信息: - ACL 名称:home_network(您可以随意命名。无空格) - 来自 IP:允许使用 Squid 的第一个 IP。例如,您可以输入 192.168.1.0,这将允许所有以 192.168.1 开头的 IP。 - 目标 IP:输入允许的最后一个 IP,或者您可以再次使用 192.168.1.0 - 网络掩码:输入您的子网掩码(255.255.255.0)

点击保存。这将返回到访问控制屏幕。点击顶部的“代理限制”。现在点击添加代理限制。点击操作旁边的允许按钮,并突出显示“home_network”,或上面你命名的 ACL。点击保存。

现在,您将在列表底部看到新条目。在右侧,单击向上箭头,将新 ACL 移动到操作为“拒绝”且 ACL 为全部的行上方。(应该是一次移动)在屏幕的最顶部单击“应用更改”。然后返回主 Squid 代理服务器页面。单击停止 Squid,允许其停止,然后单击启动 Squid。

现在,您已在服务器上完成 Squid 的设置。现在我们需要允许您分配给 Squid 的端口通过防火墙。如果您使用 iptables,请将以下行添加到 iptables:-A INPUT -p tcp –dport 3128 -j ACCEPT

相关内容