squid绑定传出ip

squid bind outgoing ip

我在同一台服务器上有很多 ip,我正在使用 squid 基本身份验证。

示例 - 我有两个 ips 和 2 个用户以及一个端口 3128。问题是任何用户都可以使用任何传出 ips。

下面是我的squid配置:

acl http proto http
acl port_80 port 80
acl port_443 port 443
acl CONNECT method CONNECT

auth_param basic program  /usr/bin/python /path/to/authenticationscript
auth_param basic realm Please enter username and password
auth_param basic credentialsttl 1 second

acl AuthUsers proxy_auth REQUIRED

external_acl_type userip %SRC %LOGIN /usr/lib/squid/ext_file_userip_acl -f /path/to/config.file
acl userip external userip

http_access allow userip
http_access deny all

http_port 3128 name=0
acl ip1 myportname 0
tcp_outgoing_address x.x.x.0 ip1

acl ip2 myportname 1
tcp_outgoing_address x.x.x.1 ip2

其中 x.x.x.x 是服务器的 IP 地址。

在config.file我有

x.x.x.0(ipaddress1) user1
x.x.x.1(ipaddress2) user2

如何让一个用户连接一个ip?

我找到了解决方案。

我需要将 http_port 和 myportname 的 acl 更改为以下内容:

http_port 3128
acl ip1 myip x.x.x.0
tcp_outgoing_address x.x.x.0 ip1

acl ip2 myip x.x.x.1
tcp_outgoing_address x.x.x.1 ip2