Squid proxy How to filter or block a particular port

Q. I am using Debian stable Linux version and squid proxy server for our small software company. I need to block a port number 1234. How to filter a particular port?

Advertisement

A. You can easily filter any port with squid ACL (Access Control List).

ACL is used for defining an access List. When using “file” the file should contain one item per line By default, regular expressions are CASE-SENSITIVE. To make them case-insensitive, use the -i option.

Procedure to block a port

First open /etc/squid/squid.conf file
# vi /etc/squid/squid.conf
Locate your ACL section and add configuration directive as follows:
acl block_port port 1234
http_access deny block_port
http_access allow all

If you just want to skip a particular IP (192.168.1.5) try as follows:
acl block_port port 1234
acl no_block_port_ip src 192.168.1.5
http_access deny block_port !no_block_port_ip
http_access allow all

Close and save the file.

Restart squid proxy server:
# /etc/init.d/squid restart

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

15 comments… add one
  • Sanjay Oct 13, 2011 @ 5:55

    Hello,

    I have a RHEL 5 Proxy server. my client on Window XP or Window Vista.
    How can I block any user MAC Address to access Internet

    Please guide me.

  • Sopha Mar 27, 2012 @ 8:16

    i want allow and block website by physical address in squid.
    how can i do ?
    but with ip4 i already done.

  • vinod Oct 3, 2015 @ 11:16

    how to access whatsApp from squid 3.1

  • M fiaz Sep 21, 2016 @ 4:15

    i want to block the port 443 on proxy server squid.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.