squid配置记录

2018-03-21  本文已影响178人  不排版

1 书籍 http://www.phpfans.net/manu/Squid/

2 ssl配置 http://zoufeng.net/2017/09/23/squid-proxy-with-ssl-bump/

3 centos 配置代理

http_proxy=http://127.0.0.1:8080/

ftp_proxy=http://yourproxy:8080/

export http_proxy

export ftp_proxy

4 https://wiki.squid-cache.org/ConfigExamples 配置例子

1 步骤

./configure --prefix=/opt/squid_ssl --enable-icmp --enable-kill-parent-hack --with-maxfd=65535 --with-dl --with-large-files --enable-poll --enable-linux-netfilter --enable-large-cache-files --enable-delay-pools --enable-snmp --enable-underscore --enable-arp-acl --enable-cache-digests --enable-err-language=”Simplify_Chinese” --enable-default-err-languages=”Simplify_Chinese” -disable-internal-dns --enable-http-violations --disable-ident-lookups --disable-carp --with-openssl --enable-gnuregex --enable-silent-rules --enable-dependency-tracking --with-openssl --enable-delay-pools --enable-useragent-log --enable-esi --enable-follow-x-forwarded-for --enable-auth --enable-async-io=240

chown -R jbuser.jbuser /opt/squid/var

squid -zX

squid -sD

squid -k shutdown

squid -k reconfigure

在 cron 里使用如下命令来处理日志:

0 4 * * * /usr/local/squid/sbin/squid -k rotate

////转发配置//

/etc/sysctl.conf

net.ipv4.ip_forward = 1

sysctl -p

////////防火墙//////////

iptables -F

/etc/init.d/iptables save

iptables -t nat -L -n

//本机

iptables -t nat -A PREROUTING -d 127.0.0.1 -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:3128

iptables -t nat -A OUTPUT -s localhost -p tcp --d localhostport 80 -j REDIRECT --to-ports 127.0.0.1:3128

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3128

iptables –t nat –A PREROUTING –i eth0 –p tcp --dport 80 –j REDIRECT --to-ports 3128

iptables -t nat -I PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128

iptables -t nat -I PREROUTING -i eth0 -s 127.0.0.1 -p tcp --dport 443 -j REDIRECT --to-port 3128

//入站重定向删除

iptables -t nat -D PREROUTING 1

//出站删除

iptables -t nat -D OUTPUT 1

/etc/init.d/iptables save

acl qq dstdomain www.baidu.com

/////////////////////////////////////////////////////////配置例子(不包含https)///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Recommended minimum configuration:

cache_effective_user jbuser

cache_dir ufs /opt/squid_ssl/var/cache 10240 16 256

Example rule allowing access from your local networks.

Adapt to list your (internal) IP networks from where browsing

should be allowed

acl localnet src 10.0.0.0/8 # RFC1918 possible internal network

acl localnet src 172.16.0.0/12 # RFC1918 possible internal network

acl localnet src 192.168.0.0/16 # RFC1918 possible internal network

acl localnet src fc00::/7 # RFC 4193 local private network range

acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines

acl Uploads method GET

acl SSL_ports port 443

acl Safe_ports port 80 # http

acl Safe_ports port 21 # ftp

acl Safe_ports port 443 # https

acl Safe_ports port 70 # gopher

acl Safe_ports port 210 # wais

acl Safe_ports port 1025-65535 # unregistered ports

acl Safe_ports port 280 # http-mgmt

acl Safe_ports port 488 # gss-http

acl Safe_ports port 591 # filemaker

acl Safe_ports port 777 # multiling http

acl CONNECT method CONNECT

acl qq dstdomain .appjfjb.com

acl http proto HTTP

acl FTP proto FTP

acl IPForHostname dstdom_regex ^[0-9]+.[0-9]+.[0-9]+.[0-9]+$

Recommended minimum Access Permission configuration:

Deny requests to certain unsafe ports

http_access deny !Safe_ports

Deny CONNECT to other than secure SSL ports

http_access deny CONNECT !SSL_ports

Only allow cachemgr access from localhost

http_access allointenw localhost manager

http_access deny manager

We strongly recommend the following be uncommented to protect innocent

web applications running on the proxy server who think the only

one who can access services on "localhost" is a local user

http_access deny to_localhost

INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS

Example rule allowing access from your local networks.

Adapt localnet in the ACL section to list your (internal) IP networks

from where browsing should be allowed

http_access allow localnet

http_access allow localhost

http_access allow qq

And finally deny all other access to this proxy

http_access allow alhttp_access allow qhttp_access allow qq

http_access deny http

http_access allow qq

http_access deny IPForHostname

http_access deny all

Squid normally listens to port 3128

http_port 3128

http_port 3128 ssl-bump cert=/opt/squid_ssl/example.com.cert key=/opt/squid_ssl/example.com.private generate-host-certificates=on version=1 options=NO_SSLv2,NO_SSLv3,SINGLE_DH_USE

https_port 3130 cert=/opt/squid_ssl/example.com.cert key=/opt/squid_ssl/example.com.private ssl-bump intercept generate-host-certificates=on version=1 options=NO_SSLv2,NO_SSLv3,SINGLE_DH_USE

ssl_bump stare all

ssl_bump bump all

Uncomment and adjust the following to add a disk cache directory.

cache_dir ufs /usr/local/squid/var/cache/squid 100 16 256

Leave coredumps in the first cache dir

coredump_dir /opt/squid_ssl/var/cache/squid

Add any of your own refresh_pattern entries above these.

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

上一篇下一篇

猜你喜欢

热点阅读