====== Squid ======
[[wp>Squid_(software)|Squid]] is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages.
===== Installation =====
yum install squid
systemctl start squid
===== HTTP basic authenication =====
touch /etc/squid/passwd && chown squid /etc/squid/passwd
htpasswd /etc/squid/passwd [username]
Edit ''/etc/squid/squid.conf'':
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic children 5
auth_param basic realm Squid Basic Authentication
auth_param basic credentialsttl 2 hours
acl auth_users proxy_auth REQUIRED
http_access allow auth_users
And reload squid:
systemctl reload squid
===== Specify domain throught proxy =====
Squid 实现代理分流
acl proxyrule dstdomain [example1.org] [example2.org]
cache_peer [proxy:ip] parent [proxy:port] 0 round-robin proxy-only no-query name=px
cache_peer_access px allow proxyrule
never_direct allow proxyrule
''never_direct allow proxyrule'' 需要打个重点标记,加了后就 **能解决某些请求不经过 cache_peer 的问题** 。
===== Reference =====
* [[https://hostpresto.com/community/tutorials/how-to-install-and-configure-squid-proxy-on-centos-7/|How to Install and Configure Squid Proxy on CentOS 7]]
* [[https://wiki.squid-cache.org/SquidFaq/SquidAcl|Access Controls in Squid]]