Configure squid 3.5 to use different parent proxies for different listening ports

7,249

Solution 1

Thanks for help, finally found working configuration (thanks guys from squid mailing list)

http_port 3128 name=port_3128
http_port 3127 name=port_3127

nonhierarchical_direct off

acl port_3128_acl myportname port_3128
acl port_3127_acl myportname port_3127

always_direct deny port_3128_acl
always_direct deny port_3127_acl

never_direct allow port_3128_acl
never_direct allow port_3127_acl

# 3128
cache_peer proxy1 parent 3128 0 proxy-only default  name=proxy3128
cache_peer_access proxy3128 allow port_3128_acl
cache_peer_access proxy3128 deny all

# 3127 
cache_peer proxy2 parent 3128 0 proxy-only default  name=proxy3127
cache_peer_access proxy3127 allow port_3127_acl
cache_peer_access proxy3127 deny all

Solution 2

It seems to be possible, but honestly I have not tried it before . You can combine acl and cache_peer_access to control what traffic is forwarded to which peer.

acl first_port myport 3128
cache_peer_access proxy1_address allow first_port

You may need to have a look at squid documentation page. Also, here is an example of using it for multiple backend servers.

Share:
7,249

Related videos on Youtube

bonzaster
Author by

bonzaster

Updated on September 18, 2022

Comments

  • bonzaster
    bonzaster over 1 year

    I have following configuration now:

    # Squid normally listens to port 3128
    http_port 3128
    
    cache_peer proxy1_address parent proxy1_port 0 proxy-only default login=name1:pass1
    never_direct allow all
    

    Now I need to configure squid in a way when all incoming requests to 3128 will be redirected to proxy1 (as it works now), and all incoming requests to 3127 will be redirected to proxy2. Is it possible to do?

    My current configuration is not working:

    http_port 3128
    http_port 3127
    
    acl port_3128 port 3128
    acl port_3127 port 3127
    
    # 3128
    cache_peer proxy01 parent 3128 0 no-query originserver name=proxy3128
    cache_peer_access proxy3128 allow port_3128
    cache_peer_access proxy3128 deny port_3127
    
    # 3127 
    cache_peer proxy02 parent 3128 0 no-query originserver name=proxy3127
    cache_peer_access proxy3127 allow port_3127
    cache_peer_access proxy3127 deny port_3128