Squid, SquidGuard, and Lightsquid
Jim Pingle
ESF, LLC
March 2014 Hangout
What are Squid, SquidGuard, and LightSquid?
● Squid is a caching proxy for HTTP and other protocols
– Can speed up access by locally caching commonly loaded sites/objects
– Can save bandwidth by reducing multiple duplicate downloads
– Allows further action on web traffic (access control, reporting)
● SquidGuard is used for access control based on the URL requested by
a client
– Decisions can be made to allow or deny access based on client or destination
– Blocked sites can be redirected to an error page in most cases
– Custom lists of sites or preset blacklists from other sources
● Lightsquid is used for reporting web access history
– Parses squid's log, notes who went where, how much bandwidth they used,
and other factors
– Has reports for daily use, monthly, and so on
– Does not work for NanoBSD
Will Squid work for me?
● Before starting, determine if Squid suits the situation
● Without squid, you cannot take an action based on the contents of HTTP
packets.
– In pf, all that may be seen is the destination IP and port number, not hostname
– Hostnames can resolve to many IP addresses, random sets, cannot be effectively
tracked with aliases in many cases.
– As a proxy, squid sees the whole HTTP transaction including the requested site name
● Squid can transparently capture HTTP, not HTTPS
● In future versions HTTPS capturing is possible but still requires installing a trusted root CA on
clients
● HTTPS can be handled by manual proxy configuration, or via WPAD or similar
● Squid is not easily compatible with Multi-WAN
● SquidGuard tests based on client and destination URL, not page content
● Squid can help by caching static content, but many pages are dynamic and
may not cache well or at all so the savings may not significant
● On NanoBSD, it can only be used for access control, not caching
What will be covered?
● Squid 2.7.x + SquidGuard - Proven stable configuration
● Reporting with Lightsquid, sqstat
● Transparent proxy of HTTP traffic
● Manual browser configuration for HTTP/HTTPS
● Blocking sites with SquidGuard
● Blacklists and Target Categories
● Custom ACLs
● Error messages and redirects
What will NOT be covered?
● WPAD, Proxy Auto Configure
● Moving Squid cache to an additional disk
● SquidGuard Schedules
● External authentication sources such as LDAP with SquidGuard
● Squid 3.x
● Sarg
● Anything related to Multi-WAN – Squid traffic will always take
the default gateway
● Interactions with Captive Portal
● Secondary/Upstream Caches
● HAVP
Prerequisites for Setup
● For the purposes of this presentation...
● Firewall VM – Clean config, no packages.
● Client VM – Basic client, just an OS and a web
browser
● Ensure you have working DNS and routing on the
firewall
● Install packages from System > Packages on the
Available Packages tab
● Install Squid (2.7.x!)
● Install SquidGuard (Not -devel or -squid3!)
● Install Lightsquid
Configure Squid – Main Tab
● Squid Settings are located under Services > Proxy Server
● Proxy Interface - Select the local interface, e.g. LAN/LAN2/Wifi –
Sets squid to Listen
● Allow users on interface - check – automatically adds ACLs
● Transparent Proxy - check to intercept HTTP requests
● Bypass options
– Source is for client IP addresses
– Destination is for remote IP addresses (servers)
– Do not use hostnames here. Use aliases if you must use hostnames
● Logging (only required for reporting), rotation
– Not viable for NanoBSD
● Proxy port - leave at 3128
Configure Squid – Main Tab (cont'd)
●
hostname and e-mail - for error messages
● Disable X-Forward
– Does not disclose the true internal client IP to the remote server.
– Setting this is best for privacy.
●
Disable Via
– Hides the fact that a proxy is involved, for security, privacy, or technical reasons.
– If you did not also disable X-Forward, a web server can still detect a proxy!
● Suppress Squid Version
– Hides the squid version in the Via HTTP headers, for security, privacy, or technical reasons.
– If Disable Via is checked, this setting does not matter as the entire squid Via header is
omitted.
● Custom Options
– Manually enter your own squid directives
– SquidGuard and others may put settings here
– If you don't know what they are, they are best left as-is
Configure Squid – Cache Mgmt Tab
● Hard disk cache size - in MB, set to 0 on NanoBSD
– Be careful with large caches. On 32-bit, Squid takes about 10MBytes of RAM
per 1GB of cache. On 64-bit, it takes 14MBytes of RAM per 1GB of cache.
● Hard disk cache system - ufs, or null for NanoBSD
● Hard disk cache location - directory, defaults to /var/squid/cache
● Memory cache size – This does not specify a maximum for squid, just
for caching objects in RAM. Can be exceeded if required for a specific
request.
● Object sizes
– Minimum Object Size: Smaller than this not saved to disk
– Maximum Object Size: Larger than this not saved to disk. Speed = Low,
Bandwidth saving = High
– Maximum Object Size in RAM: Smaller than this will be put in memory cache.
Squid – Access Control Tab
● Allowed Subnets - typically not needed when
using "allow users on interface" but if needed,
enter (Additional) subnets here
● Banned hosts, whitelist, blacklist - not typically
used with SquidGuard
● External Cache Managers - make sure LAN IP
is listed or sqstat can fail with 403 error
– If sqstat will be accessed from another interface,
add it here too (e.g. WAN IP, Management LAN IP)
Squid – Traffic Mgmt Tab
● Sizes are in Kilo*bytes*, not bits – Important to remember for the
throttling settings. Set to 0 to disable limits.
● Max down/up sizes – Careful, can break updates
● Throttling – Overall and per-host
● Throttle extensions
– Binary Files: bin, cab, sea, ar, arj, tar, tgz, gz, tbz, bz2, zip, 7z, exe,
com
– CD images: iso, bin, mds, nrg, gho, bwt, b5t, pqi
– Multimedia: aif/aiff, asf, avi, divx, mov, mp3, mp4, wmv, mpg/mpeg, qt,
ram/rm
– Other extensions
●
Custom list, just put in the letters in the extension
● NO spaces between items!
● Example: vmx,vdi,ova
Squid – Auth Settings tab
● Not used with transparent mode, but can be
setup to use local authentication, LDAP,
RADIUS, or NT Domain login
Squid settings complete! On to SquidGuard
SquidGuard
● SquidGuard Settings may be found at Services
> Proxy Filter
● SquidGuard is used for allowing or denying
based on the URL requested by the client (e.g.
domain name, part of URL) and the client itself
● Currently does NOT filter based on text inside
page
SquidGuard – General Tab
● Check the box to Enable
● ALWAYS RETURN HERE AND APPLY AFTER
CHANGES!!
● Logging, enable/rotate
● Clean advertising
– Looks for blacklists with _ads or _adv in name, URLs in these
lists get replaced with blank image
● Blacklists
– MESD – Free to use by all: http://squidguard.mesd.k12.or.us/
– Shalla – Free for non-commercial use: http://www.shallalist.de/
– Others: http://www.squidguard.org/blacklists.html
SquidGuard – Blacklist Tab
● Used for downloading the blacklist archive
defined on the General Settings tab
● Progress is displayed while downloading the list
and updating the databases
● Database update can take a long time
especially on slow hardware or systems with
slow disks
SquidGuard – Define Categories
● Categories can be defined manually, using
blacklists, or both
● For blacklists, define the blacklist archive URL
on the general tab and then use the Blacklist
tab to download the blacklist
● For custom categories, use the "Target
Categories" tab
SquidGuard – Target Categories
●
Custom lists to block or pass
● Name – Name for this Target Category
● Ordering
– Important when making whitelists, reorder those to the top when possible
● Domain list
– Most common
– Will block subdomains also. For example "facebook.com" also blocks "apps.facebook.com"
– Does not block other domains that overlap in name, for example "facebook.com" does not
block "ihatefacebook.com"
● URL List
– Similar to domain list but matches both domain and URL
– Example: google.com/maps/
● Regular Expression
– Matches portions of a URL based on regex patterns.
– Example from the GUI: mail|casino|game|.rsdf$
● Redirect Mode/Redirect – Will cover that under Common ACL
SquidGuard – Common ACL
●
Default category actions for everyone that is not matched by an ACL
● Each category appears in the list, both custom and from blacklists
● Access types:
– “---” - No action taken for this later category
– allow – Allow if never blocked
●
If the site is in a later category that is Denied, it will still be blocked!
– whitelist – Allow even if blocked
– deny – Do not allow access
● To deny access to all web sites by default, set "Default access [all]" to "deny".
Other lists would then generally be used as whitelists of approved sites.
● Do not allow IP Addresses in URL
– Will not let users connect to http://x.x.x.x/ forcing the use of hostnames instead.
– Some sites will load properly if you address them that way, and a user could bypass the
protections in place.
● Proxy Denied Error
● If using the internal error page, this text will be placed at the top of the generated
error page.
SquidGuard – Common ACL (cont'd)
● Redirect Mode:
– Select the type and enter a proper value in the box if needed.
– none - Deny content without displaying a formal error.
– Internal Error Page: Enter an error message in the box, displayed with other blocked page details
– Internal Blank Page: Returns an HTML page, but blank
– Internal Blank Image: Returns an image file, but blank (Useful for Ad blocking)
– External URL Error Page
●
Appears to the browser as the actual requested page
●
Cannot include other files unless they are inline in the html (no external css, images, etc)
●
Automatically has SquidGuard variables appended to pass the requested URL, client IP/name, group, target to the script
– External URL Redirect: Same as "External URL Error Page" except it does not append the request variables
– External URL Move - Redirects with 301
● Client browser is redirected to an external error page but in a way the client browser knows that it happens (301)
● 301 is a permanent redirect, and browsers will often cache it as such
● Since it is an external page, it can use any external resources you like
●
Does not get the request variables appended, but you can add them yourself (?a=%a&n=%n&i=%i&s=%s&t=%t&u=%u)
●
Because it is an external page in a separate request, your ACLs in squidGuard must allow access to the page if it is remote
– External URL Found - Redirects with 302
● Same as above but uses a 302 response
● 302 is temporary so the browser will keep trying the original URL for later requests
● Use SafeSearch engine
– For known search engines, forces the use of the "safesearch" mechanism to prevent loading of adult material
SquidGuard – Group ACL Tab
● Similar to Common ACL but applies to only a specific set of users
● Name – Custom name of the ACL (e.g. user's name, workgroup, set of users)
● Order – Make sure to list more specific ACLs (e.g. 192.168.1.5) ahead of more
general ones (192.168.1.0/24) so that your desired actions will take place
● Client (source)
– Entries separated by space
– IP adresses, subnets, IP Ranges, hostnames, or usernames (if using user auth without
transparent mode)
● Time – Schedule used for "off-time" decisions. Not covered in this presentation.
● Target Rules
– Same mechanism as Common ACL
– Must specify an action for ALL categories for which an action should be taken
– Does NOT “fall through” to common ACL settings
– Left column is used with or without schedules
– If a time is chosen, left column is inside the time period, right column is outside
● Other options are the same as Common ACL
SquidGuard – Times Tab
● Defines schedules for use with ACLs
● Examples: WorkTime, LunchHour, Weekend,
WorkWeek
● Not covering details of this today
SquidGuard – Log tab
● For viewing squidguard logs generated by the GUI and other
actions
● Blocked: Blocked sites, if logged
● Filter GUI Log: Messages about the squidGuard GUI
configuration
● Filter Log: SquidGuard process events
● Proxy Config: View of the squid configuration file
● Filter Config: View of the squidGuard configuration file
SquidGuard Configuration Complete! On to Lightsquid
Configure Lightsquid
●
Lightsquid is used for reporting user activity logged by the squid proxy
● Lightsquid is located at Status > Proxy Report
● Enable logging in squid first!
● Language: Language for the report (e.g. English)
● Bar Color: Color for bars in graphs
●
Report Scheme: Theme to use for the report (look/feel)
● IP Resolve Method
– Used for future parsing, will not reparse old records
– IP - IP Address only, no parsing
– Demo - Authname if known, then DNS if known, then IP
– DNS - Resolves by reverse DNS if possible
●
Useful if registering DHCP in DNS and using the right DNS server, or if you have another local DNS
server
– Simple - Authname if known, otherwise IP
– SMB - SMB name of PC (resolves via NetBIOS?)
– Squidauth - Authname from squid, otherwise IP
Configure Lightsquid (cont'd)
● Refresh Scheduler
– Sets up a cron job to automatically reparse squid
access log and update the report
– Depending on the speed of the box and the activity in
the logs, 30m-60m are good times, or less often if the
report is viewed infrequently.
● Refresh Now: Update the report now
● Refresh Full: Generate the full report again now
(best to use this when making the first report)
● Skip URL: List of URLs to not report (e.g.
monitoring systems, internal pages, etc)
Lightsquid Reports
● Status > Proxy Report, Lightsquid Report tab
● Access report by year, month, day
– Most common to click on Day in main report
● Top sites list
– Can be sorted by Bytes or Connections
● Totals
– Total bandwidth used by a client over all time
● Day report shows users that made connections on that
specific day
– Click on IP in the report to get a list of sites they visited
● "Big Files"
– List of files larger than a few MB and who downloaded those files
Lightsquid – Proxy State (sqstat)
● RealTime view of squid downloads
● NOT a live view of the access log
● Error (1): Cannot get data. Server answered:
HTTP/1.0 403 Forbidden
– Fix by adding IPs on the firewall to squid's Access
Control tab, "External Cache-Managers"
– IP to add would be the one you reach the GUI for
management. If you come across LAN, use LAN IP. If
managing remotely, use WAN IP(s).
Lightsquid Complete! Now for testing...
Browser Tests
●
Use Incognito Mode, Private Browsing Mode, etc. Avoid issues with cached
redirects.
● Load a proxy test page such as http://www.lagado.com/proxy-test
●
Load a normal unblocked/whitelisted web page
●
Load a blocked web page - internal error (e.g. www.facebook.com)
●
Load a blocked web page - external error (e.g. www.bing.com)
●
Load HTTPS version of blocked page – oops, still works
● Configure browser for proxy (varies by OS/Browser)
– Set to use the IP address of the firewall on port 3128 as proxy for all
● Load blocked HTTPS page again, now it doesn't load
● Load a normal HTTPS page, it loads OK
●
Can block 443 on LAN rules if desired
●
After loading some sites, manually refresh lightsquid and then load the report
again to see if reporting works
Other Notes
● Caching Windows Updates and AV updates
– Mixed success. See the article on the doc wiki for refresh pattern
recommendations
● Swap State File
– Not generally a problem now, but in some rare cases can grow
large/fill up FS.
● Squid randomly dies w/Signal 6
– If Squid stops working after a reboot and seems to die randomly, or
runs extremely slowly, odds are that the cache is corrupt
– Run:
● mv /var/squid/cache /var/squid/cache.old
● squid -z
● rm -rf /var/squid/cache.old
● Restart squid in GUI while the rm runs. Takes long time w/large cache
That's All!
● Questions – Time allowing
● Possible future revisit for some items not
covered

More Related Content

PDF
Squid, SquidGuard, and Lightsquid on pfSense 2.3 & 2.4 - pfSense Hangout Janu...
PDF
Local DNS with pfSense 2.4 - pfSense Hangout April 2018
PDF
Providing Local DNS with pfSense - pfSense Hangout August 2016
PDF
Bandwidth Monitoring - pfSense Hangout March 2015
PPTX
OpenvSwitch Deep Dive
PDF
A crash course in CRUSH
PPTX
NGINX: High Performance Load Balancing
PDF
Advanced OpenVPN Concepts - pfSense Hangout September 2014
Squid, SquidGuard, and Lightsquid on pfSense 2.3 & 2.4 - pfSense Hangout Janu...
Local DNS with pfSense 2.4 - pfSense Hangout April 2018
Providing Local DNS with pfSense - pfSense Hangout August 2016
Bandwidth Monitoring - pfSense Hangout March 2015
OpenvSwitch Deep Dive
A crash course in CRUSH
NGINX: High Performance Load Balancing
Advanced OpenVPN Concepts - pfSense Hangout September 2014

What's hot (20)

PDF
Monitoring pfSense 2.4 with SNMP - pfSense Hangout March 2018
PDF
Let's Encrypt - pfSense Hangout April 2017
PDF
An introduction to SSH
PPTX
Linux and DNS Server
PDF
GRE (generic routing encapsulation)
PDF
Technical tips for secure Apache Hadoop cluster #ApacheConAsia #ApacheCon
PPT
Introduction to SSH
PPTX
NGINX: Basics and Best Practices
PDF
L3HA-VRRP-20141201
PPTX
Disaster Recovery Experience at CACIB: Hardening Hadoop for Critical Financia...
PDF
Advanced Captive Portal - pfSense Hangout June 2017
PPT
Ganglia Monitoring Tool
PPT
Virtual private network
PDF
Traffic Shaping Basics with PRIQ - pfSense Hangout February 2016
PDF
PDF
Introduction to OpenFlow
PPT
dynamic host configuration protocol
PDF
Inside neutron 2
PPTX
VXLAN
PPT
Monitoring pfSense 2.4 with SNMP - pfSense Hangout March 2018
Let's Encrypt - pfSense Hangout April 2017
An introduction to SSH
Linux and DNS Server
GRE (generic routing encapsulation)
Technical tips for secure Apache Hadoop cluster #ApacheConAsia #ApacheCon
Introduction to SSH
NGINX: Basics and Best Practices
L3HA-VRRP-20141201
Disaster Recovery Experience at CACIB: Hardening Hadoop for Critical Financia...
Advanced Captive Portal - pfSense Hangout June 2017
Ganglia Monitoring Tool
Virtual private network
Traffic Shaping Basics with PRIQ - pfSense Hangout February 2016
Introduction to OpenFlow
dynamic host configuration protocol
Inside neutron 2
VXLAN
Ad

Similar to Squid, SquidGuard, and Lightsquid - pfSense Hangout March 2014 (20)

ODP
Nagios Conference 2014 - Andy Brist - Nagios XI Failover and HA Solutions
PDF
pfSense 2.4.4 Short Topic Miscellany - pfSense Hangout August 2018
PDF
Squid proxy server
PDF
Monitoring with Ganglia
PDF
Optimizing Your Frontend Performance
PDF
Linuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux Admins
PPTX
Shall we play a game
PDF
Shall we play a game?
PDF
Gdb basics for my sql db as (percona live europe 2019)
PDF
Proper Care and Feeding of a MySQL Database for Busy Linux Administrators
PPTX
Choosing A Proxy Server - Apachecon 2014
PDF
We shall play a game....
PDF
OSMC 2017 | Troubleshooting-icinga 2 by Thomas Widhalm
PDF
Screaming Fast Wpmu
PDF
Live traffic capture and replay in cassandra 4.0
PDF
The Proper Care and Feeding of a MySQL Database for Busy Linux Admins -- SCaL...
ODP
Ubuntu And Parental Controls
PDF
IPv6 Basics - pfSense Hangout July 2015
PDF
The Accidental DBA
Nagios Conference 2014 - Andy Brist - Nagios XI Failover and HA Solutions
pfSense 2.4.4 Short Topic Miscellany - pfSense Hangout August 2018
Squid proxy server
Monitoring with Ganglia
Optimizing Your Frontend Performance
Linuxfest Northwest Proper Care and Feeding Of a MySQL for Busy Linux Admins
Shall we play a game
Shall we play a game?
Gdb basics for my sql db as (percona live europe 2019)
Proper Care and Feeding of a MySQL Database for Busy Linux Administrators
Choosing A Proxy Server - Apachecon 2014
We shall play a game....
OSMC 2017 | Troubleshooting-icinga 2 by Thomas Widhalm
Screaming Fast Wpmu
Live traffic capture and replay in cassandra 4.0
The Proper Care and Feeding of a MySQL Database for Busy Linux Admins -- SCaL...
Ubuntu And Parental Controls
IPv6 Basics - pfSense Hangout July 2015
The Accidental DBA
Ad

More from Netgate (20)

PDF
Using Google Cloud Identity Secure LDAP with pfSense - Netgate Hangout Octobe...
PDF
Configuring Netgate Appliance Integrated Switches on pfSense 2.4.4 - pfSense ...
PDF
Routed IPsec on pfSense 2.4.4 - pfSense Hangout June 2018
PDF
RADIUS and LDAP on pfSense 2.4 - pfSense Hangout February 2018
PDF
User Management and Privileges on pfSense 2.4 - pfSense Hangout January 2018
PDF
Dynamic Routing with FRR - pfSense Hangout December 2017
PDF
Firewall Best Practices for VoIP on pfSense - pfSense Hangout October 2017
PDF
Certificate Management on pfSense 2.4 - pfSense Hangout September 2017
PDF
Backup and Restore with pfSense 2.4 - pfSense Hangout August 2017
PDF
Server Load Balancing on pfSense 2.4 - pfSense Hangout July 2017
PDF
High Availability on pfSense 2.4 - pfSense Hangout March 2017
PDF
Advanced OpenVPN Concepts on pfSense 2.4 & 2.3.3 - pfSense Hangout February 2017
PDF
Console Menu - pfSense Hangout December 2016
PDF
OpenVPN as a WAN - pfSense Hangout October 2016
PDF
DHCP Server - pfSense Hangout September 2016
PDF
High Availability Part 2 - pfSense Hangout July 2016
PDF
Connectivity Troubleshooting - pfSense Hangout June 2016
PDF
NAT on pfSense 2.3 - pfSense Hangout May 2016
PDF
Multi-WAN on pfSense 2.3 - pfSense Hangout March 2016
PDF
Creating a DMZ - pfSense Hangout January 2016
Using Google Cloud Identity Secure LDAP with pfSense - Netgate Hangout Octobe...
Configuring Netgate Appliance Integrated Switches on pfSense 2.4.4 - pfSense ...
Routed IPsec on pfSense 2.4.4 - pfSense Hangout June 2018
RADIUS and LDAP on pfSense 2.4 - pfSense Hangout February 2018
User Management and Privileges on pfSense 2.4 - pfSense Hangout January 2018
Dynamic Routing with FRR - pfSense Hangout December 2017
Firewall Best Practices for VoIP on pfSense - pfSense Hangout October 2017
Certificate Management on pfSense 2.4 - pfSense Hangout September 2017
Backup and Restore with pfSense 2.4 - pfSense Hangout August 2017
Server Load Balancing on pfSense 2.4 - pfSense Hangout July 2017
High Availability on pfSense 2.4 - pfSense Hangout March 2017
Advanced OpenVPN Concepts on pfSense 2.4 & 2.3.3 - pfSense Hangout February 2017
Console Menu - pfSense Hangout December 2016
OpenVPN as a WAN - pfSense Hangout October 2016
DHCP Server - pfSense Hangout September 2016
High Availability Part 2 - pfSense Hangout July 2016
Connectivity Troubleshooting - pfSense Hangout June 2016
NAT on pfSense 2.3 - pfSense Hangout May 2016
Multi-WAN on pfSense 2.3 - pfSense Hangout March 2016
Creating a DMZ - pfSense Hangout January 2016

Recently uploaded (20)

PDF
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
PPTX
Module 1 Introduction to Web Programming .pptx
PDF
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
PPTX
Internet of Everything -Basic concepts details
PDF
Human Computer Interaction Miterm Lesson
PDF
Early detection and classification of bone marrow changes in lumbar vertebrae...
PDF
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
PDF
EIS-Webinar-Regulated-Industries-2025-08.pdf
PDF
Rapid Prototyping: A lecture on prototyping techniques for interface design
PDF
Ensemble model-based arrhythmia classification with local interpretable model...
PDF
INTERSPEECH 2025 「Recent Advances and Future Directions in Voice Conversion」
PDF
SaaS reusability assessment using machine learning techniques
PPTX
Microsoft User Copilot Training Slide Deck
PDF
NewMind AI Weekly Chronicles – August ’25 Week IV
PDF
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
PDF
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
PDF
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
PDF
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
PDF
Data Virtualization in Action: Scaling APIs and Apps with FME
PDF
Lung cancer patients survival prediction using outlier detection and optimize...
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
Module 1 Introduction to Web Programming .pptx
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
Internet of Everything -Basic concepts details
Human Computer Interaction Miterm Lesson
Early detection and classification of bone marrow changes in lumbar vertebrae...
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
EIS-Webinar-Regulated-Industries-2025-08.pdf
Rapid Prototyping: A lecture on prototyping techniques for interface design
Ensemble model-based arrhythmia classification with local interpretable model...
INTERSPEECH 2025 「Recent Advances and Future Directions in Voice Conversion」
SaaS reusability assessment using machine learning techniques
Microsoft User Copilot Training Slide Deck
NewMind AI Weekly Chronicles – August ’25 Week IV
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
MENA-ECEONOMIC-CONTEXT-VC MENA-ECEONOMIC
Data Virtualization in Action: Scaling APIs and Apps with FME
Lung cancer patients survival prediction using outlier detection and optimize...

Squid, SquidGuard, and Lightsquid - pfSense Hangout March 2014

  • 1. Squid, SquidGuard, and Lightsquid Jim Pingle ESF, LLC March 2014 Hangout
  • 2. What are Squid, SquidGuard, and LightSquid? ● Squid is a caching proxy for HTTP and other protocols – Can speed up access by locally caching commonly loaded sites/objects – Can save bandwidth by reducing multiple duplicate downloads – Allows further action on web traffic (access control, reporting) ● SquidGuard is used for access control based on the URL requested by a client – Decisions can be made to allow or deny access based on client or destination – Blocked sites can be redirected to an error page in most cases – Custom lists of sites or preset blacklists from other sources ● Lightsquid is used for reporting web access history – Parses squid's log, notes who went where, how much bandwidth they used, and other factors – Has reports for daily use, monthly, and so on – Does not work for NanoBSD
  • 3. Will Squid work for me? ● Before starting, determine if Squid suits the situation ● Without squid, you cannot take an action based on the contents of HTTP packets. – In pf, all that may be seen is the destination IP and port number, not hostname – Hostnames can resolve to many IP addresses, random sets, cannot be effectively tracked with aliases in many cases. – As a proxy, squid sees the whole HTTP transaction including the requested site name ● Squid can transparently capture HTTP, not HTTPS ● In future versions HTTPS capturing is possible but still requires installing a trusted root CA on clients ● HTTPS can be handled by manual proxy configuration, or via WPAD or similar ● Squid is not easily compatible with Multi-WAN ● SquidGuard tests based on client and destination URL, not page content ● Squid can help by caching static content, but many pages are dynamic and may not cache well or at all so the savings may not significant ● On NanoBSD, it can only be used for access control, not caching
  • 4. What will be covered? ● Squid 2.7.x + SquidGuard - Proven stable configuration ● Reporting with Lightsquid, sqstat ● Transparent proxy of HTTP traffic ● Manual browser configuration for HTTP/HTTPS ● Blocking sites with SquidGuard ● Blacklists and Target Categories ● Custom ACLs ● Error messages and redirects
  • 5. What will NOT be covered? ● WPAD, Proxy Auto Configure ● Moving Squid cache to an additional disk ● SquidGuard Schedules ● External authentication sources such as LDAP with SquidGuard ● Squid 3.x ● Sarg ● Anything related to Multi-WAN – Squid traffic will always take the default gateway ● Interactions with Captive Portal ● Secondary/Upstream Caches ● HAVP
  • 6. Prerequisites for Setup ● For the purposes of this presentation... ● Firewall VM – Clean config, no packages. ● Client VM – Basic client, just an OS and a web browser ● Ensure you have working DNS and routing on the firewall ● Install packages from System > Packages on the Available Packages tab ● Install Squid (2.7.x!) ● Install SquidGuard (Not -devel or -squid3!) ● Install Lightsquid
  • 7. Configure Squid – Main Tab ● Squid Settings are located under Services > Proxy Server ● Proxy Interface - Select the local interface, e.g. LAN/LAN2/Wifi – Sets squid to Listen ● Allow users on interface - check – automatically adds ACLs ● Transparent Proxy - check to intercept HTTP requests ● Bypass options – Source is for client IP addresses – Destination is for remote IP addresses (servers) – Do not use hostnames here. Use aliases if you must use hostnames ● Logging (only required for reporting), rotation – Not viable for NanoBSD ● Proxy port - leave at 3128
  • 8. Configure Squid – Main Tab (cont'd) ● hostname and e-mail - for error messages ● Disable X-Forward – Does not disclose the true internal client IP to the remote server. – Setting this is best for privacy. ● Disable Via – Hides the fact that a proxy is involved, for security, privacy, or technical reasons. – If you did not also disable X-Forward, a web server can still detect a proxy! ● Suppress Squid Version – Hides the squid version in the Via HTTP headers, for security, privacy, or technical reasons. – If Disable Via is checked, this setting does not matter as the entire squid Via header is omitted. ● Custom Options – Manually enter your own squid directives – SquidGuard and others may put settings here – If you don't know what they are, they are best left as-is
  • 9. Configure Squid – Cache Mgmt Tab ● Hard disk cache size - in MB, set to 0 on NanoBSD – Be careful with large caches. On 32-bit, Squid takes about 10MBytes of RAM per 1GB of cache. On 64-bit, it takes 14MBytes of RAM per 1GB of cache. ● Hard disk cache system - ufs, or null for NanoBSD ● Hard disk cache location - directory, defaults to /var/squid/cache ● Memory cache size – This does not specify a maximum for squid, just for caching objects in RAM. Can be exceeded if required for a specific request. ● Object sizes – Minimum Object Size: Smaller than this not saved to disk – Maximum Object Size: Larger than this not saved to disk. Speed = Low, Bandwidth saving = High – Maximum Object Size in RAM: Smaller than this will be put in memory cache.
  • 10. Squid – Access Control Tab ● Allowed Subnets - typically not needed when using "allow users on interface" but if needed, enter (Additional) subnets here ● Banned hosts, whitelist, blacklist - not typically used with SquidGuard ● External Cache Managers - make sure LAN IP is listed or sqstat can fail with 403 error – If sqstat will be accessed from another interface, add it here too (e.g. WAN IP, Management LAN IP)
  • 11. Squid – Traffic Mgmt Tab ● Sizes are in Kilo*bytes*, not bits – Important to remember for the throttling settings. Set to 0 to disable limits. ● Max down/up sizes – Careful, can break updates ● Throttling – Overall and per-host ● Throttle extensions – Binary Files: bin, cab, sea, ar, arj, tar, tgz, gz, tbz, bz2, zip, 7z, exe, com – CD images: iso, bin, mds, nrg, gho, bwt, b5t, pqi – Multimedia: aif/aiff, asf, avi, divx, mov, mp3, mp4, wmv, mpg/mpeg, qt, ram/rm – Other extensions ● Custom list, just put in the letters in the extension ● NO spaces between items! ● Example: vmx,vdi,ova
  • 12. Squid – Auth Settings tab ● Not used with transparent mode, but can be setup to use local authentication, LDAP, RADIUS, or NT Domain login Squid settings complete! On to SquidGuard
  • 13. SquidGuard ● SquidGuard Settings may be found at Services > Proxy Filter ● SquidGuard is used for allowing or denying based on the URL requested by the client (e.g. domain name, part of URL) and the client itself ● Currently does NOT filter based on text inside page
  • 14. SquidGuard – General Tab ● Check the box to Enable ● ALWAYS RETURN HERE AND APPLY AFTER CHANGES!! ● Logging, enable/rotate ● Clean advertising – Looks for blacklists with _ads or _adv in name, URLs in these lists get replaced with blank image ● Blacklists – MESD – Free to use by all: http://squidguard.mesd.k12.or.us/ – Shalla – Free for non-commercial use: http://www.shallalist.de/ – Others: http://www.squidguard.org/blacklists.html
  • 15. SquidGuard – Blacklist Tab ● Used for downloading the blacklist archive defined on the General Settings tab ● Progress is displayed while downloading the list and updating the databases ● Database update can take a long time especially on slow hardware or systems with slow disks
  • 16. SquidGuard – Define Categories ● Categories can be defined manually, using blacklists, or both ● For blacklists, define the blacklist archive URL on the general tab and then use the Blacklist tab to download the blacklist ● For custom categories, use the "Target Categories" tab
  • 17. SquidGuard – Target Categories ● Custom lists to block or pass ● Name – Name for this Target Category ● Ordering – Important when making whitelists, reorder those to the top when possible ● Domain list – Most common – Will block subdomains also. For example "facebook.com" also blocks "apps.facebook.com" – Does not block other domains that overlap in name, for example "facebook.com" does not block "ihatefacebook.com" ● URL List – Similar to domain list but matches both domain and URL – Example: google.com/maps/ ● Regular Expression – Matches portions of a URL based on regex patterns. – Example from the GUI: mail|casino|game|.rsdf$ ● Redirect Mode/Redirect – Will cover that under Common ACL
  • 18. SquidGuard – Common ACL ● Default category actions for everyone that is not matched by an ACL ● Each category appears in the list, both custom and from blacklists ● Access types: – “---” - No action taken for this later category – allow – Allow if never blocked ● If the site is in a later category that is Denied, it will still be blocked! – whitelist – Allow even if blocked – deny – Do not allow access ● To deny access to all web sites by default, set "Default access [all]" to "deny". Other lists would then generally be used as whitelists of approved sites. ● Do not allow IP Addresses in URL – Will not let users connect to http://x.x.x.x/ forcing the use of hostnames instead. – Some sites will load properly if you address them that way, and a user could bypass the protections in place. ● Proxy Denied Error ● If using the internal error page, this text will be placed at the top of the generated error page.
  • 19. SquidGuard – Common ACL (cont'd) ● Redirect Mode: – Select the type and enter a proper value in the box if needed. – none - Deny content without displaying a formal error. – Internal Error Page: Enter an error message in the box, displayed with other blocked page details – Internal Blank Page: Returns an HTML page, but blank – Internal Blank Image: Returns an image file, but blank (Useful for Ad blocking) – External URL Error Page ● Appears to the browser as the actual requested page ● Cannot include other files unless they are inline in the html (no external css, images, etc) ● Automatically has SquidGuard variables appended to pass the requested URL, client IP/name, group, target to the script – External URL Redirect: Same as "External URL Error Page" except it does not append the request variables – External URL Move - Redirects with 301 ● Client browser is redirected to an external error page but in a way the client browser knows that it happens (301) ● 301 is a permanent redirect, and browsers will often cache it as such ● Since it is an external page, it can use any external resources you like ● Does not get the request variables appended, but you can add them yourself (?a=%a&n=%n&i=%i&s=%s&t=%t&u=%u) ● Because it is an external page in a separate request, your ACLs in squidGuard must allow access to the page if it is remote – External URL Found - Redirects with 302 ● Same as above but uses a 302 response ● 302 is temporary so the browser will keep trying the original URL for later requests ● Use SafeSearch engine – For known search engines, forces the use of the "safesearch" mechanism to prevent loading of adult material
  • 20. SquidGuard – Group ACL Tab ● Similar to Common ACL but applies to only a specific set of users ● Name – Custom name of the ACL (e.g. user's name, workgroup, set of users) ● Order – Make sure to list more specific ACLs (e.g. 192.168.1.5) ahead of more general ones (192.168.1.0/24) so that your desired actions will take place ● Client (source) – Entries separated by space – IP adresses, subnets, IP Ranges, hostnames, or usernames (if using user auth without transparent mode) ● Time – Schedule used for "off-time" decisions. Not covered in this presentation. ● Target Rules – Same mechanism as Common ACL – Must specify an action for ALL categories for which an action should be taken – Does NOT “fall through” to common ACL settings – Left column is used with or without schedules – If a time is chosen, left column is inside the time period, right column is outside ● Other options are the same as Common ACL
  • 21. SquidGuard – Times Tab ● Defines schedules for use with ACLs ● Examples: WorkTime, LunchHour, Weekend, WorkWeek ● Not covering details of this today
  • 22. SquidGuard – Log tab ● For viewing squidguard logs generated by the GUI and other actions ● Blocked: Blocked sites, if logged ● Filter GUI Log: Messages about the squidGuard GUI configuration ● Filter Log: SquidGuard process events ● Proxy Config: View of the squid configuration file ● Filter Config: View of the squidGuard configuration file SquidGuard Configuration Complete! On to Lightsquid
  • 23. Configure Lightsquid ● Lightsquid is used for reporting user activity logged by the squid proxy ● Lightsquid is located at Status > Proxy Report ● Enable logging in squid first! ● Language: Language for the report (e.g. English) ● Bar Color: Color for bars in graphs ● Report Scheme: Theme to use for the report (look/feel) ● IP Resolve Method – Used for future parsing, will not reparse old records – IP - IP Address only, no parsing – Demo - Authname if known, then DNS if known, then IP – DNS - Resolves by reverse DNS if possible ● Useful if registering DHCP in DNS and using the right DNS server, or if you have another local DNS server – Simple - Authname if known, otherwise IP – SMB - SMB name of PC (resolves via NetBIOS?) – Squidauth - Authname from squid, otherwise IP
  • 24. Configure Lightsquid (cont'd) ● Refresh Scheduler – Sets up a cron job to automatically reparse squid access log and update the report – Depending on the speed of the box and the activity in the logs, 30m-60m are good times, or less often if the report is viewed infrequently. ● Refresh Now: Update the report now ● Refresh Full: Generate the full report again now (best to use this when making the first report) ● Skip URL: List of URLs to not report (e.g. monitoring systems, internal pages, etc)
  • 25. Lightsquid Reports ● Status > Proxy Report, Lightsquid Report tab ● Access report by year, month, day – Most common to click on Day in main report ● Top sites list – Can be sorted by Bytes or Connections ● Totals – Total bandwidth used by a client over all time ● Day report shows users that made connections on that specific day – Click on IP in the report to get a list of sites they visited ● "Big Files" – List of files larger than a few MB and who downloaded those files
  • 26. Lightsquid – Proxy State (sqstat) ● RealTime view of squid downloads ● NOT a live view of the access log ● Error (1): Cannot get data. Server answered: HTTP/1.0 403 Forbidden – Fix by adding IPs on the firewall to squid's Access Control tab, "External Cache-Managers" – IP to add would be the one you reach the GUI for management. If you come across LAN, use LAN IP. If managing remotely, use WAN IP(s). Lightsquid Complete! Now for testing...
  • 27. Browser Tests ● Use Incognito Mode, Private Browsing Mode, etc. Avoid issues with cached redirects. ● Load a proxy test page such as http://www.lagado.com/proxy-test ● Load a normal unblocked/whitelisted web page ● Load a blocked web page - internal error (e.g. www.facebook.com) ● Load a blocked web page - external error (e.g. www.bing.com) ● Load HTTPS version of blocked page – oops, still works ● Configure browser for proxy (varies by OS/Browser) – Set to use the IP address of the firewall on port 3128 as proxy for all ● Load blocked HTTPS page again, now it doesn't load ● Load a normal HTTPS page, it loads OK ● Can block 443 on LAN rules if desired ● After loading some sites, manually refresh lightsquid and then load the report again to see if reporting works
  • 28. Other Notes ● Caching Windows Updates and AV updates – Mixed success. See the article on the doc wiki for refresh pattern recommendations ● Swap State File – Not generally a problem now, but in some rare cases can grow large/fill up FS. ● Squid randomly dies w/Signal 6 – If Squid stops working after a reboot and seems to die randomly, or runs extremely slowly, odds are that the cache is corrupt – Run: ● mv /var/squid/cache /var/squid/cache.old ● squid -z ● rm -rf /var/squid/cache.old ● Restart squid in GUI while the rm runs. Takes long time w/large cache
  • 29. That's All! ● Questions – Time allowing ● Possible future revisit for some items not covered