用户工具

站点工具


linux:squid

Squid

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:

/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

linux/squid.txt · 最后更改: 2023/12/03 10:24 由 127.0.0.1