Squid是什么?
squid是一个完全支持HTTP/1.0、HTTP/1.1和HTTPS的代理服务器,提供了多种访问控制、认证和日志方式,以便用户可以便捷的搭建web代理和应用,不仅如此,squid还提供了一系列丰富的优化选项,大多数默认开启。
安装
官网提供的下载包 http://www.squid-cache.org/Versions/
我这里下载的是squid-3.1.23的版本,下载地址为 http://www.squid-cache.org/Versions/v3/3.1/
安装记录
tar -xzf squid-3.1.23.tar.gz
cd squid-3.1.23
./configure options: '--prefix=/path/to/squid' --enable-ltdl-convenience
make
sudo make install
启动&使用
启动服务
安装完成之后会在安装目录里生成一个配置文件etc/squid.conf, 这个文件配置默认是可用的,监听的端口是3128
完整的使用方法 见 squid -h
squid [-cdhvzCFNRVYX] [-s | -l facility] [-f config-file] [-[au] port] [-k signal] -a port 监听的http端口 (默认: 3128). -d level Write debugging to stderr also. -f file 配置文件路径 -h Print help message. -k reconfigure|rotate|shutdown|interrupt|kill|debug|check|parse Parse configuration file, then send signal to running copy (except -k parse) and exit. -s | -l facility Enable logging to syslog. -u port Specify ICP port number (default: 3130), disable with 0. -v Print version. -z Create swap directories -C Do not catch fatal signals. -D OBSOLETE. Scheduled for removal. -F Don't serve any requests until store is rebuilt. -N No daemon mode. -R Do not set REUSEADDR on port. -S Double-check swap during rebuild. -X Force full debugging. -Y Only return UDP_HIT or UDP_MISS_NOFETCH during fast reload.
启动squid -f /path/to/squid/etc/squid.conf
使用
curl -x 127.0.0.1:3128 -I https://www.baidu.com
HTTP/1.0 200 Connection established HTTP/1.1 200 OK Accept-Ranges: bytes Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform Connection: Keep-Alive Content-Length: 277 Content-Type: text/html Date: Wed, 31 Oct 2018 05:01:31 GMT Etag: "575e1f60-115" Last-Modified: Mon, 13 Jun 2016 02:50:08 GMT Pragma: no-cache Server: bfe/1.0.8.18
如上squid搭建代理完成
官网地址 http://www.squid-cache.org