squid的简单配置

简介:

squid 命令

squid 启动squid

squid -k reconfigure 重新加载配置文件

squid -k parse 检查配置文件是否出现语法错误

squid -k shutdown 停止squid

squid -z 生成缓存目录

acl 列表名称

  • proto:指明URL访问/传输协议。如:http、https、ftp、gopher、urn、whois、cache_object。

  • src:指明IP地址。

  • dst:指明最终服务器IP。

  • port:单独定义端口/端口范围。

  • method:指http的请求方法。包括GET、POST、PUT、HEAD、CONNECT等

squid.普通正向代理服务:正向代理是代理客户端,为客户端收发请求,使真实客户端对服务器不可见;

http_port 192.168.200.157:3128         #代理服务器squid的ip 及其端口号                                     
acl manager proto cache_object #定义访问的协议 为cache_object
acl localnet src 192.168.200.0/24 #所要代理的客户端网段
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1  #这个不清楚

acl badsite dstdomain www.51cto.com #dstdomain为代理服务器所指向网站的服务器域名.
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

http_access allow manager localnet 
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports

http_access deny badsite #禁止访问badsite所代表的网站


maximum_object_size 4 MB  
minimum_object_size 0 kB
maximum_object_size_in_memory 4096 KB
coredump_dir /var/spool/squid #squid挂掉后,临终遗言要放到哪里,一般也不需要处理

cache_dir ufs /var/spool/squid 100 16 256


cache_log /var/log/squid/cache.log  #定义了些日至存放的路径
cache_access_log /var/log/squid/access.log
cache_store_log /var/log/squid/store.log

logfile_rotate 10 #日志轮询10天
cache_swap_high 95 #cache占用95%时,开始清理cache,清理到90%

cache_swap_low 90
cache_mem 8 MB #额外占用的内存,可自己定义

cache_effective_user squid #启动squid的用户,和用户组
cache_effective_group squid 
cache_mgr 862350707@qq.com #管理员邮箱.


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       



在客户端浏览器firefox中,

Preferences->Advanced->settings

设置squid代理服务器的ip和端口




squid反向代理服务器:反向代理是代理服务器端,为服务器收发请求,使真实服务器对客户端不可见。

修改上述文件

http_port 192.168.200.157:3128 accel vhost #注意这里accel vhost只有为反向代理时才有

cache_peer 192.168.200.158 parent 80 0 //真实的web服务器ip为158.


本文转自神ge 51CTO博客,原文链接:http://blog.51cto.com/12218412/1868780

相关文章
Squid 安装与配置
本文转载自:https://help.aliyun.com/knowledge_detail/41342.html Squid 介绍 Squid 是一个缓存 Internet 数据的软件,其接收用户的下载申请,并自动处理所下载的数据。
1498 0
|
7天前
|
缓存 Ubuntu Python
Squid中正向代理的配置与使用
Squid中正向代理的配置与使用
|
缓存 网络协议 PHP
|
Web App开发 开发工具
|
网络协议 缓存 开发工具
|
Web App开发 缓存 监控