Squid proxy How to filter or block a particular port

ht‮‬tps://www.lautturi.com
Squid proxy How to filter or block a particular port

To filter or block a particular port through a Squid proxy, you can use the acl and http_access directives in the Squid configuration file.

  1. Create an access control list (ACL): The acl directive allows you to define a group of IP addresses, URLs, or other criteria that you want to allow or deny access to. To block a particular port, you can create an ACL that matches the port number.

For example, to block all traffic on port 8080, you can use the following acl directive:

acl block_8080 port 8080
  1. Use the http_access directive to control access: The http_access directive allows you to specify which ACLs are allowed or denied access to the Squid proxy. To block access to a particular port, you can use the http_access directive to deny access to the ACL that you created in step 1.

For example, to block all traffic on port 8080, you can use the following http_access directive:

http_access deny block_8080

This will block all traffic on port 8080 through the Squid proxy.

You can also use the http_access directive to allow access to specific ports while blocking others. For example, to allow access to port 80 and block access to all other ports, you can use the following acl and http_access directives:

acl block_all_ports port 1-65535
http_access deny block_all_ports
http_access allow 80

This will allow access to port 80 and block access to all other ports through the Squid proxy.

Keep in mind that you will need to have root privileges to modify the Squid configuration file. You will also need to restart Squid for the changes to take effect.

Created Time:2017-10-30 14:27:20  Author:lautturi