选择显示字体大小

使用squid加快内网网页浏览速度

同事们总是抱怨上国外网站速度很慢,半天网页都打不开,于是使用squid和ipfilter实现透明代理,为他们提供缓存功能。

@ 安装squid
为了偷懒就直接使用ports安装,因为我将所有的服务器系统都安装在/s分区中,所以设置了prefix为/s/squid
# cd /usr/ports/www/squid
# setenv prefix /s/squid
# make install clean

安装完成后编辑/s/squid/etc/squid/squid.conf,我的配置内容如下:

########## base control ##########
cache_mgr webmaster
cache_effective_user squid
cache_effective_group squid
visible_hostname sleepcat.3322.org
http_port 127.0.0.1:3128
icp_port 0
cache_dir ufs /usr/cache 300 16 256
cache_access_log /dev/null
cache_log /dev/null
cache_store_log /dev/null
error_directory /s/squid/etc/squid/errors/simplify_chinese
icon_directory /s/squid/etc/squid/icons
mime_table /s/squid/etc/squid/mime.conf
coredump_dir /s/squid/squid/cache
pid_filename /s/squid/squid/logs/squid.pid
hosts_file /etc/hosts
unlinkd_program /s/squid/libexec/squid/unlinkd

########## performance control ##########
cache_mem 8 mb
cache_swap_low 90
cache_swap_high 95
maximum_object_size 4096 kb
minimum_object_size 0 kb
maximum_object_size_in_memory 8 kb
ipcache_size 1024
ipcache_low 90
ipcache_high 95
fqdncache_size 1024
cache_replacement_policy lru
memory_replacement_policy lru
emulate_httpd_log off
log_ip_on_direct on
log_mime_hdrs off
dns_timeout 2 minutes
request_header_max_size 10 kb
request_body_max_size 0 kb
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
negative_ttl 5 minutes
positive_dns_ttl 6 hours
negative_dns_ttl 1 minute
connect_timeout 1 minute
read_timeout 15 minutes
request_timeout 5 minutes
client_lifetime 1 day
half_closed_clients on
maximum_single_addr_tries 1
uri_whitespace strip
ie_refresh off

########## access control ############
acl all src 0.0.0.0/0.0.0.0
http_access allow all
http_reply_access allow all
hierarchy_stoplist cgi-bin ?

########## accelator control ############
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on

########## misc control ###########
ftp_user squid@
ftp_list_width 32
ftp_passive on
ftp_sanitycheck on


初始化cache
# /s/squid/sbin/squid -z

启动squid
# /s/squid/etc/rc.d/squid.sh start

@ 设置ipfilter
为了实现透明的功能,需要将所有对80端口的请求转到squid的3128端口上,以实现对客户端透明的功能。在/etc/ipnat.rules中加入:
rdr fxp1 0.0.0.0/0 port 80 -> 127.0.0.1 3128

刷新ipnat配置:
# ipnat -cf /etc/ipnat.rules

一切完成,客户端无需任何设置,根本感觉不到代理的存在,而且访问速度明显变快。

  


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons