客户端连接到不同的代理

时间:2019-05-16 00:21:28

标签: proxy squid

我需要在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

我应该怎么做?

1 个答案:

答案 0 :(得分:1)

# 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