Squid web cache and proxy
Read: Squid-2.6 configuration manual http://www.visolve.com/squid/squid26/contents.php
Squid-3.0
Install on Ubuntu-9.10 - yea I hate IPv6, or any other half-ass bullshit../configure --with-aio --with-openssl=/usr --with-large-files \ --enable-stacktraces --enable-linux-netfilter --enable-ssl \ --enable-kill-parent-hack --enable-delay-pools \ --enable-storeio=ufs,aufs --enable-icmp \ --sysconfdir=/etc/squid3 --localstatedir=/var --disable-ipv6
Squid2.7
My install on FreeBSD:./configure \ --localstatedir=/var \ --sysconfdir=/etc/squid \ --enable-icmp \ --enable-ssl \ --enable-large-cache-files \ --enable-storeio=ufs,aufs
Squid Redhat init script
Squid logs in UTC
Easy.convert_utc.pl
Setting up squid-2.6 as reverse proxy
I'm not gonna bore you with the details. Just add these in additional to the stock config file.http_port SQUID_EXTERNAL_IP:80 vhost vport
cache_peer REAL_WEB_IP parent 80 0 originserver default
httpd_accel_uses_host_header on
acl valid_dst dstdomain .accelerated.com
http_access allow valid_dst
http_access deny all
cache_peer REAL_WEB_IP parent 80 0 originserver default
httpd_accel_uses_host_header on
acl valid_dst dstdomain .accelerated.com
http_access allow valid_dst
http_access deny all
Setting up Squid 2.4/2.5 as reversed proxy
Edit your squid.conf with the followings:
Some basic tuning
cache_mem 256 MB
minimum_object_size 0 KB
maximum_object_size 2048 KB
maximum_object_size_in_memory 128 KB
ident_timeout 1 seconds
cache_dir aufs /var/spool/squid 1024 16 256 #1G cache, 16 level1, 256 level2
buffered_logs on
redirect_rewrites_host_header off
emulate_httpd_log on
minimum_object_size 0 KB
maximum_object_size 2048 KB
maximum_object_size_in_memory 128 KB
ident_timeout 1 seconds
cache_dir aufs /var/spool/squid 1024 16 256 #1G cache, 16 level1, 256 level2
buffered_logs on
redirect_rewrites_host_header off
emulate_httpd_log on
Reverse-proxy (accelerator) settings
# Squid 2.5 reverse proxy settings
http_port 1.2.3.4:80
httpd_accel_host 10.1.1.1
httpd_accel_port 80
httpd_accel_single_host on
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
http_port 1.2.3.4:80
httpd_accel_host 10.1.1.1
httpd_accel_port 80
httpd_accel_single_host on
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
Now edit the ACL so access is granted
# ACL settings
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_local dst 10.1.1.0/255.255.255.0
acl to_web dst 1.2.3.4/255.255.255.255
acl safe_ports port 80
acl SSL_ports port 443
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny !safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow to_local
http_access allow to_web
http_access deny all
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_local dst 10.1.1.0/255.255.255.0
acl to_web dst 1.2.3.4/255.255.255.255
acl safe_ports port 80
acl SSL_ports port 443
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny !safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow to_local
http_access allow to_web
http_access deny all
URL filter
acl allowed_url url_regex ^.*/photos/.*
acl allowed_url url_regex ^.*/jacked/.*
http_access allow allowed_url
http_access deny all
acl allowed_url url_regex ^.*/jacked/.*
http_access allow allowed_url
http_access deny all
Now change your web server to listen on 127.0.0.1:80, start your web server and squid!
Squid URL acl
Set up the acl the http_access listacl whitelist_domains dstdomain "/etc/squid/whitelist.domains" acl blacklist_domains dstdomain "/etc/squid/blacklist.domains" http_access deny blacklist_domains http_access allow trusted_net whitelist_domains
Then create the .domains files
.blah.com .foo.com
Squid authentication (for forward proxies)
From squid's sourcecd helpers/basic_auth/NCSA/ make make install
Then add these into squid.conf
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/passwd auth_param basic children 5 auth_param basic realm My Proxy Server auth_param basic credentialsttl 2 hours auth_param basic casesensitive on acl authusers proxy_auth REQUIRED http_access allow authusers http_access deny all tcp_outgoing_address 1.2.3.4 # if you want to mask your outgoing address
Then just create the passwd file with htpasswd
cache_peer
One can configure squid to pass request to another squid based on the dst domain:# define cache_peer cache_peer 10.8.0.6 parent 3128 3130 proxy-only name=xxx-squid # define list of domains acl dp-domains dstdomain .xxx.net acl dp-domains dstdomain .xxx.com # tell squid to use xxx-squid for xxx-domains cache_peer_access xxx-squid allow xxx-domains # Stop squid from trying to DIRECT ssl requests for xxx-domains never_direct allow xxx-domains
Reference:
http://www.midgard-project.org/documentation/setting-up-squid-reverse-proxy/#82a98852b0640fad5d6810758b8d5c3f
http://squid.visolve.com/
There are no comments on this page. [Add comment]