首页 > 解决方案 > 客户端连接到不同的代理

问题描述

我需要在 Ubuntu 上使用 squid 将不同的客户端连接到不同的代理,并且它们不应该连接到彼此的代理。看看这个例子:

client 1 (ip 1.1.1.1) > squidservre.com:1000 > someproxyserver:1234
client 2 (ip 2.2.2.2) > squidserver.com:1001 > someproxyserver:1235
client 3......

客户端 1 不应该连接到 1001 端口,服务器应该拒绝他,因为客户端 2 也不应该连接到端口 1000,它应该被拒绝

现在我正在使用下面的代码,但问题是每个客户端都可以连接到其他代理:

acl port_1 localport 10001
acl port_2 localport 10002
acl port_3 localport 10003 
# Squid ports
http_port 10001 
http_port 10002
http_port 10003

cache_peer Proxyserverip parent 1234 0 name=host_1 no-query default
cache_peer Proxyserverip parent 1235 0 name=host_2 no-query default
cache_peer Proxyserverip parent 1236 0 name=host_3 no-query default

cache_peer_access host_1 allow port_1
cache_peer_access host_2 allow port_2
cache_peer_access host_3 allow port_3
never_direct allow all

acl mysour src 1.1.1.1 #client 1
acl mysour src 2.2.2.2 #client 2

http_access allow mysour
http_access deny all

我需要指定每个客户端连接它自己的端口,服务器会将他连接到他自己的 Proxyserverip

我该怎么做?

标签: proxysquid

解决方案


# Define port ACLs
acl port_1 localport 10001
acl port_2 localport 10002
acl port_3 localport 10003

# Define client IP ACLs
acl client_1 src 127.0.0.1
acl client_2 src 127.0.0.2
acl client_3 src 127.0.0.3

# Cache peer (replace PROXY_1, PROXY_2 and PROXY_3 with your proxy IPs)
never_direct allow all
cache_peer PROXY_1 parent 1234 0 name=host_1 no-query default
cache_peer PROXY_2 parent 1235 0 name=host_2 no-query default
cache_peer PROXY_3 parent 1236 0 name=host_3 no-query default
cache_peer_access host_1 allow port_1
cache_peer_access host_2 allow port_2
cache_peer_access host_3 allow port_3

# Define which ports specific clients can access
http_access allow client_1 port_1
http_access allow client_2 port_2
http_access allow client_3 port_3
http_access deny all

# Listening ports
http_port 10001 
http_port 10002
http_port 10003

# Additional config settings here

推荐阅读