Skip to content

Instantly share code, notes, and snippets.

@salrashid123
Last active May 21, 2021 10:10
Show Gist options
  • Save salrashid123/97c6daa35467e36a6d0928f3b6787285 to your computer and use it in GitHub Desktop.
Save salrashid123/97c6daa35467e36a6d0928f3b6787285 to your computer and use it in GitHub Desktop.
Minimal squid.conf to deny destination host
1) create a file squid.conf
```
acl denydomain dstdomain .bbc.com
http_access deny denydomain
acl allowdomain dstdomain .yahoo.com
http_access allow allowdomain
http_access deny all
http_port 3128
access_log /apps/squid/var/logs/access.log squid
cache_log /apps/squid/var/logs/cache.log squid
```
2) then run the squid-proxy image i setup and reference the file via volume:
# docker run -v `pwd`:/tmp/squid/ -p 3128:3128 -t salrashid123/squidproxy /apps/squid/sbin/squid -NsY -f /tmp/squid/squid.conf
@salrashid123
Copy link
Author

in a new window use curl and specify the proxy:

you'll see it allows yahoo over http and https but denies all other domains

$ curl -x localhost:3128  -o /dev/null -s  -w "%{http_code}\n" -L https://www.bbc.com/
000

$ curl -x localhost:3128  -o /dev/null -s  -w "%{http_code}\n" -L https://www.bbc.com/
000  

$ curl -x localhost:3128  -o /dev/null -s  -w "%{http_code}\n" -L http://www.bbc.com/
403
$ curl -x localhost:3128  -o /dev/null -s  -w "%{http_code}\n" -L https://www.yahoo.com/
200

$ curl -x localhost:3128  -o /dev/null -s  -w "%{http_code}\n" -L http://www.yahoo.com/
200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment