≡ Menu

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

Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 13 comments… add one }

  • Anees May 28, 2007, 6:57 am

    i want to block to some site not ports how i block tham plz help me.Thanks

  • nixCraft May 28, 2007, 2:48 pm
  • Partha Bhattacharya August 5, 2007, 9:21 am

    Opened ACL.But could not understand where to write the configuration changes as u have stated.Plz help its urgent.

  • Yagnes February 19, 2008, 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

  • Yagnes February 19, 2008, 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

  • jasper moore January 18, 2009, 5:50 am

    Thank for the blocking stuff.

  • Asaduzzaman June 14, 2009, 6:52 am

    We are unable to access following url from squid proxy, could you please assist us how can I access this url using squid proxy server.
    http://tx1.kewill-ipacs.com:18080/kewillfwd/app/kewillfwd.jnlp

    • nixCraft June 14, 2009, 2:15 pm

      Add port number to Safe_port list in squid.conf

  • chellapandi August 24, 2009, 12:54 pm

    How to black the job site for linux proxy server. i am using RHEL4.

  • vm loganathan December 23, 2009, 1:08 pm

    sir,
    i’m using redhad 5 server edition. i config squid.config for particular websites can’t access. but now i want to particular my netwok ip’s only allowed particular website only other website totaly blocked. how do done this?..
    example
    my n/w is 191.168.0.0/255.255.0.0
    but 191.168.3.6 ip user only access gmail.com other website totally block how to done this?
    note: particular websites only i want to allow other website i want to deny how?
    how to done this plz help[replay] me….

  • Ashwin September 28, 2010, 12:02 pm

    Hello,

    Can we try multiple ip’s should be exempted in blocked search, like, –

    acl no_block_port_ip src 192.168.1.5, 192.168.1.6, 192.168.1.4
    http_access deny block_port !no_block_port_ip

    Please guide me.

  • Sanjay October 13, 2011, 5:55 am

    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 March 27, 2012, 8:16 am

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

Leave a Comment