# edit /usr/local/etc/squid/squid.conf
# egrep -v '#|^ *$' /usr/local/etc/squid/squid.conf
acl SSL_ports port 443
acl CONNECT method CONNECT
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access deny to_localhost
http_access allow localnet
http_access allow localhost
http_access deny all
http_port 127.0.0.1:3128
http_port 172.16.1.1:3128
http_port [::1]:3128
http_port [fc00::1:1]:3128
http_port 172.16.1.1:3129 ssl-bump intercept \
cert=/usr/local/etc/squid/ssl_cert/myCA.pem \
generate-host-certificates=on dynamic_cert_mem_cache_size=4MB \
dhparams=/usr/local/etc/squid/ssl_cert/dhparam.pem
http_port [fc00::1:1]:3129 ssl-bump intercept \
cert=/usr/local/etc/squid/ssl_cert/myCA.pem \
generate-host-certificates=on dynamic_cert_mem_cache_size=4MB \
dhparams=/usr/local/etc/squid/ssl_cert/dhparam.pem
https_port 172.16.1.1:3130 ssl-bump intercept \
cert=/usr/local/etc/squid/ssl_cert/myCA.pem \
generate-host-certificates=on dynamic_cert_mem_cache_size=4MB \
dhparams=/usr/local/etc/squid/ssl_cert/dhparam.pem
https_port [fc00::1:1]:3130 ssl-bump intercept \
cert=/usr/local/etc/squid/ssl_cert/myCA.pem \
generate-host-certificates=on dynamic_cert_mem_cache_size=4MB \
dhparams=/usr/local/etc/squid/ssl_cert/dhparam.pem
sslcrtd_program /usr/local/libexec/squid/ssl_crtd -s /usr/local/etc/squid/ssl_db -M 4MB
acl step1 at_step SslBump1
ssl_bump peek step1
ssl_bump stare all
ssl_bump bump all
always_direct allow all
sslproxy_cert_error allow all
sslproxy_flags DONT_VERIFY_PEER
tcp_outgoing_address 181.143.98.123
tcp_outgoing_address 2800:e7:a8:6123::3
cache_dir ufs /var/squid/cache 1000 16 256
coredump_dir /var/squid/cache
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
access_log daemon:/var/log/squid/access.log squid
visible_hostname my.cutekittens.com
cache_mgr support@cutekittens.com
# cp /etc/ssl/openssl.cnf /usr/local/etc/squid/ssl_cert
# edit /usr/local/etc/squid/ssl_cert/openssl.cnf
# egrep -v '#|^ *$' /usr/local/etc/squid/ssl_cert/openssl.cnf
...
countryName = Country Name (2 letter code)
countryName_default = US
countryName_min = 2
countryName_max = 2
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Florida
localityName = Locality Name (eg, city)
localityName_default = Miami
0.organizationName = Organization Name (eg, company)
0.organizationName_default = Cute Kittens
organizationalUnitName = Organizational Unit Name (eg, section)
organizationalUnitName_default = Systems
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_default = my.cuteKittens.com
commonName_max = 64
emailAddress = Email Address
emailAddress_default = support@cutekittens.com
...
# openssl req -new -newkey rsa:2048 -sha256 -days 36500 -nodes -x509 -extensions v3_ca -keyout myCA.pem -out /usr/local/etc/squid/ssl_cert/myCA.pem -config /usr/local/etc/squid/ssl_cert/openssl.cnf
# openssl dhparam -outform PEM -out /usr/local/etc/squid/ssl_cert/dhparam.pem 2048
# openssl x509 -in /usr/local/etc/squid/ssl_cert/myCA.pem -outform DER -out /usr/local/etc/squid/ssl_cert/myCA.der
# chown -R squid:squid /usr/local/etc/squid/ssl_cert
# chmod -R 700 /usr/local/etc/squid/ssl_cert
# /usr/local/libexec/squid/ssl_crtd -c -s /usr/local/etc/squid/ssl_db
Initialization SSL db...
Done
# chown -R squid:squid /usr/local/etc/squid/ssl_db
# chmod -R 700 /usr/local/etc/squid/ssl_db
# rm -f /usr/local/etc/squid/ssl_cert/*.pem
# rm -f /usr/local/etc/squid/ssl_cert/*.der
# rm -Rf /usr/local/etc/squid/ssl_db
# edit /etc/pf.conf
#-------------------------------------------------------------------------------
# (5) PF: Netkwork Address Translation (NAT) and Packet Redirection
#-------------------------------------------------------------------------------
# Internet (NAT IPv4 = yes | NAT IPv6 = yes)
nat on $ext_if inet from any to any -> $ext_ipv4
nat on $ext_if inet6 from any to any -> $ext_ipv6
#=================== SQUID =====================================
# PRECAUTION IN TESTING!
# Intercept HTTPS CONNECT messages with SSL-Bump
rdr pass on $int_if inet proto tcp from any to port https \
-> 172.16.1.1 port 3130
rdr pass on $int_if inet6 proto tcp from any to port https \
-> fc00::1:1 port 3130
#=================== SQUID =====================================
shutdown_lifetime 0 seconds
acl manager proto cache_object
acl localnet src 192.168.1.0/24
acl port_443 port 443
acl ports_80_443 port 80 443
acl CONNECT method CONNECT
http_access allow localhost manager
http_access deny manager
http_access deny !ports_80_443
http_access deny CONNECT !port_443
http_access deny to_localhost
http_access allow localnet
http_access deny all
http_port localhost:3127
http_port 192.168.1.35:3127
http_port 127.0.0.1:3128 intercept
https_port 127.0.0.1:3129 intercept ssl-bump generate-host-certificates=on cert=/usr/local/etc/squid/proxy-certs/proxy-ca.pem tls-dh=/usr/local/etc/squid/proxy-certs/dhparam.pem
acl step1 at_step SslBump1
ssl_bump peek step1
ssl_bump bump port_443
sslcrtd_program /usr/local/libexec/squid/security_file_certgen -s /usr/local/etc/squid/dyn-certs -M 4MB
sslcrtd_children 8 startup=3 idle=1
cache_mem 512 MB
cache_dir aufs /var/squid/cache 10000 16 256
coredump_dir /var/squid/cache
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
tls_outgoing_options cipher=EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:!RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS
tls_outgoing_options cafile=/etc/ssl/cert.pem
tls_outgoing_options options=NO_SSLv3,SINGLE_DH_USE,SINGLE_ECDH_USE
# Transparent HTTP(S) Proxy - Squid
/sbin/ipfw -q add 80 fwd 127.0.0.1,3128 tcp from 192.168.1.3,192.168.1.5,192.168.1.7,192.168.1.8,192.168.1.9 to any 80
/sbin/ipfw -q add 81 fwd 127.0.0.1,3129 tcp from 192.168.1.3,192.168.1.5,192.168.1.7,192.168.1.8,192.168.1.9 to any 443
http_port 3128 ssl-bump \
generate-host-certificates=on \
dynamic_cert_mem_cache_size=4MB \
cert=/usr/local/etc/squid/ssl/ca.pem \
tls-dh=/usr/local/squid/etc/ssl/dhparam.pem