Search code examples
proxysquid

client connect to different proxies


I need to use squid on Ubuntu to connect different clients to different proxies , and they should not connect to each others proxies.. look at this example :

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......

client 1 should not connect to port of 1001 and server should deny him as client 2 also should not connect to port 1000 and it should be denied

now i'm using the below code but the problem is every client can connect to others proxies:

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

I need to specify each client to connect it's own port and server will connect him to his own Proxyserverip

how should I do this?


Solution

  • # 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