squid使用手册第二章 squid的配置

来源:互联网 发布:窗户贴膜 知乎 编辑:程序博客网 时间:2024/05/06 21:17

创建squid需要的用户

useradd squid -s /sbin/nologin 

建立squid日志文件及修改相关权限及所有者

mkdir /usr/local/squid/var/
mkdir /usr/local/squid/var/cache
mkdir /usr/local/squid/var/logs 
mkdir /var/spool/squid
touch  /var/log/squid/logs/cache.log
touch /usr/local/squid/var/logs/cache.log
touch /usr/local/squid/var/logs/access.log
touch /usr/local/squid/var/logs/store.log
chown -R nobody  /usr/local/squid/var/cache
chown -R nobody.nobody /usr/local/squid/var
chown -R nobody /usr/local/squid/var/logs/cache.log
chown -R nobody /usr/local/squid/var/logs/access.log
chown -R nobody /usr/local/squid/var/logs/store.log


配置squid

vi /etc/squid/squid.conf
# Recommended minimum configuration:
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
# 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 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 deny_log http_status 200 206 304

http_access allow manager localhost
http_access allow all
http_access deny manager
# 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
# 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
# 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
# And finally deny all other access to this proxy
http_access deny all
# Squid normally listens to port 3128
http_port 80 vhost vport
cache_peer 192.168.3.180 parent 80 0 no-query originserver name=qqcom
cache_peer_domain qqcom  www.qq.com
cache_peer 192.168.33.180 parent 19110  0 no-query originserver name=qqcn

cache_peer_domain qqcn  www.qq.cn


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

cache_dir ufs /usr/local/squid/var/cache 1000 16 256
cache_access_log /usr/local/squid/var/logs/access.log
cache_log /usr/local/squid/var/logs/cache.log
cache_store_log /usr/local/squid/var/logs/store.log

cache_mgr 1142132456@qq.com

httpd_suppress_version_string on
# Leave coredumps in the first cache dir
coredump_dir /usr/local/squid/var/cache
negative_ttl 0 second
# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp:144020%10080
refresh_pattern ^gopher:14400%1440
refresh_pattern -i (/cgi-bin/|\?) 00%0
refresh_pattern .020%4320



出现的错误提示: cache_mem is larger than total disk cache space!

将原本的cache 100改为cache 1000

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

cache_dir参数设定使用的存储系统的类型。一般情况下都类型应该是ufs,目录应该是“/cache”,在该目录下使用的缓冲值为200MB,允许在“/cache”下创建的第一级子目录数为16,每个第一级子目录下可以创建的第二级子目录数量为256。 


原创粉丝点击