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?
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
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Linux / UNIX FAQ:
- Squid proxy authentication in transparent mode
- Squid Proxy Server Mac Address based filtering
- How to: Linux / UNIX setup Squid Proxy authentication
- Squid Block any Domain Name Accessing the Internet
- Squid content filtering: Block / download of music MP3, mpg, mpeg, exec files
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Please do not use the comment form to ask for help / question. Ask your question on the excellent Linux tech support forum. Thank you very much for stopping by our site!
~ Last updated on: April 15, 2007


May 28th, 2007 at 6:57 am
i want to block to some site not ports how i block tham plz help me.Thanks
May 28th, 2007 at 2:48 pm
Anees,
See this Squid deny users accessing a website FAQ
August 5th, 2007 at 9:21 am
Opened ACL.But could not understand where to write the configuration changes as u have stated.Plz help its urgent.
February 19th, 2008 at 6:53 am
Hi,
I tried your given the instruction port blocking for yahoo messanger, gtalk but its not working that rule..
acl porttest port 5050 5222 5223
acl block_port port 5050 5222 5223
acl test src 172.27.162.43
http_access deny block_port test
http_access allow all
Please help me how to port level blocking partiucalar src ip’s
Its possible to deny particular port ??
Thanks
Yagnes
s.yagnes@gmail.com
February 19th, 2008 at 7:00 am
Hi,
I tried your given the instruction port blocking for yahoo messanger, gtalk but its not working that rule..
acl block_port port 5050 5222 5223
acl test src 172.27.162.43
http_access deny block_port test
http_access allow all
Please help me how to port level blocking partiucalar src ip’s
Its possible to deny particular port ??
Thanks
Yagnes
s.yagnes@gmail.com