Squid+Apache配置

来源:互联网 发布:undo歌曲知乎 编辑:程序博客网 时间:2024/06/09 16:51

最近项目引入反向代理和缓存,熟悉了一下Squid、Apache、Valish、Nginx,根据项目实际进行选择,客观来说,采用Linux系统部署最好,也没有什么难度,但实际情况必须采用Windows系统(本着方案要结合现实的原则,研究要以Windows平台为主)。


一  Squid 配置:

在squid.conf配置文件末尾加上如下内容:

#show squid namevisible_hostname tg.squid-cache.jjtg.com#cache_managercache_mgr xxx@abc.com    #邮箱地址#DNS查询dns_testnames 192.168.45.45#squid监听http_port 7575 accel vhost vport#后端站点cache_peer 192.168.45.45 parent 7574 0 no-query originserver connect-timeout=180#chache_memorycache_mem 800 MBcache_swap_low 90cache_swap_high 95#cache_dir::注意路径cache_dir ufs E:/var/squid/tg/cache 100000 16 256#cache_logs::注意路径cache_log E:/var/squid/tg/logs/cache.loglogformat squid %ts.%03tu %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mtaccess_log E:/var/squid/tg/logs/access.log squidcache_store_log E:/var/squid/tg/logs/store.log#cache_log none#access_log none#cache_store_log nonepid_filename E:/var/squid/tg/logs/squid.pid#cache runnercache_effective_user squidcache_effective_group squids#隐藏不是必须的header#2.x用header_access,3.x用reply_header_accessheader_access ETag deny allheader_access Vary deny allheader_access Accept-Ranges deny allheader_access X-AspNet-Version deny allheader_access X-Powered-By deny all#禁止缓存的文件  #hierarchy_stoplist -i \.aspx \.asmx \.ashxacl NoneCache urlpath_regex -i \.aspx \.asmx \.ashxno_cache deny NoneCache  #只允许本地PUGREacl AdminBoxes src 127.0.0.1 192.168.0.0/16acl Purge method PURGEhttp_access allow AdminBoxes Purgehttp_access deny Purge #squid ACL rules#acl all src allhttp_access allow all#http_access deny all
二  Apache配置 

在httpd.conf配置文件修改:

#增加监听端口:  Listen 7570  Listen 7574    #修改ServerName:ServerName 192.168.45.45:7570#用户自定义添加代理  #开启mod_proxy,mod_proxy_connect,mod_proxy_http  #代理拦截    <VirtualHost 192.168.45.45:7574>  ServerName 192.168.45.45:7574  ProxyPass / http://192.168.45.45:7573/  ProxyPassReverse / http://192.168.45.45:7573/  </VirtualHost>    #用户自定义配置静态文件的Expires:    <IfModule mod_headers.c>  #用户自定义去掉某些不必要的Header信息  #header unset Etag  #开启mod_expires  ExpiresActive On  ExpiresByType image/x-icon "access plus 1 months"  ExpiresByType application/x-javascript "access plus 1 weeks"  ExpiresByType text/css "access plus 1 weeks"  ExpiresByType image/gif "access plus 1 months"  ExpiresByType image/png "access plus 1 months"  ExpiresByType image/jpeg "access plus 1 months"  ExpiresByType application/x-shockwave-flash "access plus 1 months"  ExpiresByType video/x-flv "access plus 1 months"  ExpiresByType application/pdf "access plus 1 months"  #ExpiresByType text/html "access plus 1 weeks"        <FilesMatch "^(.*)\.(aspx|asmx|ashx)($|.*)">          Header unset Cache-Control          Header unset Expires          Header set Cache-Control "no-cache,no-store"          Header set Pragma "no-cache"      </FilesMatch>  </IfModule>
三  修改Apache连接数:

1.修改httpd.conf文件

Include conf/extra/httpd-mpm.conf   #去掉该行的注释,引用httpd-mpm.conf文件
2.修改/extra/httpd-mpm.conf
#linux下:#原:<IfModule mpm_prefork_module>StartServers 5MinSpareServers 5MaxSpareServers 10MaxClients 150MaxRequestPerClild 0</IfModule>#改为:<IfModule mpm_prefork_module>StartServers  5MinSpareServers 5MaxSpareServers 10ServerLimit 1500MaxClients 1000MaxRequestsPerChild 0</IfModule>#windows:#原:<IfModule mpm_winnt_module>    ThreadsPerChild      150    MaxRequestsPerChild    0</IfModule>#改为:<IfModule mpm_winnt_module>    ThreadsPerChild      500    MaxRequestsPerChild    5000</IfModule>
4.改后,不能用restart重启,而要用stop停止,star启动



原创粉丝点击