Squid Proxy Cache Server
Web proxy and cache with Squid, HTTPS inspection, and monitoring.
Overview
Squid is a full-featured HTTP/HTTPS proxy server and web cache daemon that has been optimizing network performance since 1996. Originally developed for Unix-like systems, Squid acts as an intermediary between client browsers and web servers, caching frequently requested content to reduce bandwidth usage and improve response times. Its robust access control lists (ACLs) and content filtering capabilities make it a cornerstone of enterprise network security and performance optimization.
This stack combines Squid with a comprehensive monitoring solution using squid-exporter to extract proxy metrics, Prometheus to collect and store time-series data, and Grafana to visualize cache hit rates, bandwidth usage, and client access patterns. The squid-exporter specifically monitors Squid's cache performance, request patterns, and response codes, feeding this data to Prometheus for long-term storage and alerting. Grafana transforms these metrics into actionable dashboards showing cache efficiency, top requested domains, and bandwidth savings.
Network administrators managing corporate internet access, ISPs looking to reduce upstream bandwidth costs, and organizations requiring content filtering will find this stack invaluable. The monitoring layer provides visibility into proxy performance that's essential for optimizing cache policies and identifying network usage patterns. This combination is particularly valuable in environments where internet bandwidth is expensive or limited, as Squid's caching can dramatically reduce external traffic while the monitoring stack proves ROI through detailed bandwidth savings reports.
Key Features
- HTTP/HTTPS transparent and explicit proxy with SSL bump capabilities for HTTPS inspection
- Intelligent web caching with configurable storage limits and cache replacement policies
- Advanced ACL system supporting IP ranges, domains, time-based rules, and user authentication
- Real-time Squid metrics export including cache hit ratios, request rates, and storage utilization
- PromQL-powered analysis of proxy performance trends and bandwidth usage patterns
- Grafana dashboards for cache efficiency monitoring and client access visualization
- Content filtering with support for blacklists, whitelists, and custom URL patterns
- Bandwidth throttling and QoS controls for different user groups or destinations
Common Use Cases
- 1Corporate internet gateway with employee web access control and bandwidth management
- 2ISP transparent proxy deployment to reduce upstream bandwidth costs through aggressive caching
- 3Educational institution content filtering with detailed reporting on student internet usage
- 4Remote office proxy server with monitoring to optimize WAN link utilization
- 5Development environment proxy for API caching and request debugging with metrics tracking
- 6Content delivery optimization for organizations with multiple branch offices sharing cached content
- 7Compliance monitoring setup requiring detailed logs and reports of all web traffic patterns
Prerequisites
- Minimum 2GB RAM (1GB for Squid cache, 256MB each for Prometheus and Grafana, plus overhead)
- Available ports 3128 (Squid), 9090 (Prometheus), 3000 (Grafana), and 9301 (squid-exporter)
- Understanding of proxy configuration concepts including explicit vs transparent proxy modes
- Basic knowledge of Squid ACL syntax for implementing access control and filtering rules
- Network configuration access to set up client proxy settings or transparent interception
- Environment variable GRAFANA_PASSWORD set for Grafana admin authentication
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 squid: 3 image: ubuntu/squid:latest4 ports: 5 - "3128:3128"6 volumes: 7 - ./squid.conf:/etc/squid/squid.conf:ro8 - squid_cache:/var/spool/squid9 - squid_logs:/var/log/squid10 networks: 11 - squid_net1213 squid-exporter: 14 image: boynux/squid-exporter:latest15 ports: 16 - "9301:9301"17 environment: 18 - SQUID_HOSTNAME=squid19 - SQUID_PORT=312820 depends_on: 21 - squid22 networks: 23 - squid_net2425 prometheus: 26 image: prom/prometheus:latest27 ports: 28 - "9090:9090"29 volumes: 30 - ./prometheus.yml:/etc/prometheus/prometheus.yml31 - prometheus_data:/prometheus32 networks: 33 - squid_net3435 grafana: 36 image: grafana/grafana:latest37 ports: 38 - "3000:3000"39 environment: 40 - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}41 volumes: 42 - grafana_data:/var/lib/grafana43 networks: 44 - squid_net4546volumes: 47 squid_cache: 48 squid_logs: 49 prometheus_data: 50 grafana_data: 5152networks: 53 squid_net: .env Template
.env
1# Squid Proxy2GRAFANA_PASSWORD=secure_grafana_password34# Proxy at localhost:31285# Configure browser/system proxy settingsUsage Notes
- 1Proxy at localhost:3128
- 2Configure clients to use proxy
- 3Customize squid.conf for ACLs
- 4Cache improves bandwidth usage
- 5Content filtering capabilities
Individual Services(4 services)
Copy individual services to mix and match with your existing compose files.
squid
squid:
image: ubuntu/squid:latest
ports:
- "3128:3128"
volumes:
- ./squid.conf:/etc/squid/squid.conf:ro
- squid_cache:/var/spool/squid
- squid_logs:/var/log/squid
networks:
- squid_net
squid-exporter
squid-exporter:
image: boynux/squid-exporter:latest
ports:
- "9301:9301"
environment:
- SQUID_HOSTNAME=squid
- SQUID_PORT=3128
depends_on:
- squid
networks:
- squid_net
prometheus
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
networks:
- squid_net
grafana
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}
volumes:
- grafana_data:/var/lib/grafana
networks:
- squid_net
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 squid:5 image: ubuntu/squid:latest6 ports:7 - "3128:3128"8 volumes:9 - ./squid.conf:/etc/squid/squid.conf:ro10 - squid_cache:/var/spool/squid11 - squid_logs:/var/log/squid12 networks:13 - squid_net1415 squid-exporter:16 image: boynux/squid-exporter:latest17 ports:18 - "9301:9301"19 environment:20 - SQUID_HOSTNAME=squid21 - SQUID_PORT=312822 depends_on:23 - squid24 networks:25 - squid_net2627 prometheus:28 image: prom/prometheus:latest29 ports:30 - "9090:9090"31 volumes:32 - ./prometheus.yml:/etc/prometheus/prometheus.yml33 - prometheus_data:/prometheus34 networks:35 - squid_net3637 grafana:38 image: grafana/grafana:latest39 ports:40 - "3000:3000"41 environment:42 - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}43 volumes:44 - grafana_data:/var/lib/grafana45 networks:46 - squid_net4748volumes:49 squid_cache:50 squid_logs:51 prometheus_data:52 grafana_data:5354networks:55 squid_net:56EOF5758# 2. Create the .env file59cat > .env << 'EOF'60# Squid Proxy61GRAFANA_PASSWORD=secure_grafana_password6263# Proxy at localhost:312864# Configure browser/system proxy settings65EOF6667# 3. Start the services68docker compose up -d6970# 4. View logs71docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/squid-proxy-cache/run | bashTroubleshooting
- Squid 'Access Denied' errors: Check ACL rules in squid.conf and ensure client IPs are in allowed ranges
- High memory usage by Squid: Adjust cache_mem and maximum_object_size_in_memory directives in squid.conf
- squid-exporter connection refused: Verify SQUID_HOSTNAME environment variable matches service name and port 3128 is accessible
- Prometheus 'target down' for squid-exporter: Check that squid-exporter container is running and accessible on port 9301
- Grafana showing no data: Verify Prometheus data source configuration points to http://prometheus:9090
- SSL/HTTPS sites not loading through proxy: Configure SSL bump in squid.conf or disable HTTPS filtering for affected domains
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
squidsquid-exporterprometheusgrafana
Tags
#squid#proxy#cache#filtering#enterprise
Category
Web Servers & Reverse ProxiesAd Space
Shortcuts: C CopyF FavoriteD Download