|
为了感谢斑竹和各位的帮忙,我也分享一点小经验。
webmail的用户体验很重要,一个是速度,一个就是方便性,这次和大家分享一下关于webmail提速的经验。
webmail里包含两部分内容:
1、静态文件,html页面和图片,还有庞大的js。kerio web mail用了不少ajax技术,里面的js都是200多K一个的。针对这类文件,我们可以使用expire(cache)和压缩技术减少文件下载的数量和流量。
2、动态PHP程序。针对这类文件,我们可以使用xcache或者ea之类的php加速器加速,但是由于kerio使用的自己封装好的php解释器,上次尝试过修改php.ini的参数,但失败了,暂时先不搞这个。
这个方案如下:
1、用lighttpd的proxy模块转发web请求到kerio web server。
2、lighttpd开启expire和gzip功能,对静态文件进行压缩和cache。
步骤如下:
1、设置kerio web server的监听IP和端口为127.0.0.1:81
2、配置lighttpd,使用他的proxy模块转发web请求到127.0.0.1:81端口
3、配置lighttpd,启用expire和gzip模块。
使用1.5版的lighttpd,因为他有deflate模块,压缩文件更爽。
http://www.lighttpd.net/download/lighttpd-1.5.0-r1992.tar.gz
编译过程很简单,configure ; make ; make install即可。
下面给出我lighttpd.conf的配置:-
- server.modules = (
- "mod_access",
- "mod_proxy_core",
- "mod_proxy_backend_http",
- "mod_expire",
- "mod_deflate",
- "mod_accesslog" )
- server.document-root = "/opt/kerio/mailserver/webmail/"
- server.errorlog = "/usr/local/lighttpd/logs/error.log"
- index-file.names = ( "index.php", "index.html",
- "index.htm", "default.htm" )
- mimetype.assign = (
- ".pdf" => "application/pdf",
- ".sig" => "application/pgp-signature",
- ".spl" => "application/futuresplash",
- ".class" => "application/octet-stream",
- ".ps" => "application/postscript",
- ".torrent" => "application/x-bittorrent",
- ".dvi" => "application/x-dvi",
- ".gz" => "application/x-gzip",
- ".pac" => "application/x-ns-proxy-autoconfig",
- ".swf" => "application/x-shockwave-flash",
- ".tar.gz" => "application/x-tgz",
- ".tgz" => "application/x-tgz",
- ".tar" => "application/x-tar",
- ".zip" => "application/zip",
- ".mp3" => "audio/mpeg",
- ".m3u" => "audio/x-mpegurl",
- ".wma" => "audio/x-ms-wma",
- ".wax" => "audio/x-ms-wax",
- ".ogg" => "application/ogg",
- ".wav" => "audio/x-wav",
- ".gif" => "image/gif",
- ".jpg" => "image/jpeg",
- ".jpeg" => "image/jpeg",
- ".png" => "image/png",
- ".xbm" => "image/x-xbitmap",
- ".xpm" => "image/x-xpixmap",
- ".xwd" => "image/x-xwindowdump",
- ".css" => "text/css",
- ".html" => "text/html",
- ".htm" => "text/html",
- ".js" => "text/javascript",
- ".asc" => "text/plain",
- ".c" => "text/plain",
- ".cpp" => "text/plain",
- ".log" => "text/plain",
- ".conf" => "text/plain",
- ".text" => "text/plain",
- ".txt" => "text/plain",
- ".dtd" => "text/xml",
- ".xml" => "text/xml",
- ".mpeg" => "video/mpeg",
- ".mpg" => "video/mpeg",
- ".mov" => "video/quicktime",
- ".qt" => "video/quicktime",
- ".avi" => "video/x-msvideo",
- ".asf" => "video/x-ms-asf",
- ".asx" => "video/x-ms-asf",
- ".wmv" => "video/x-ms-wmv",
- ".bz2" => "application/x-bzip",
- ".tbz" => "application/x-bzip-compressed-tar",
- ".tar.bz2" => "application/x-bzip-compressed-tar"
- )
- server.tag = "Apache"
- accesslog.filename = "/usr/local/lighttpd/logs/access.log"
- url.access-deny = ( "~", ".inc" )
- static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
- server.pid-file = "/usr/local/lighttpd/logs/lighttpd.pid"
- dir-listing.activate = "disable"
- server.username = "nobody"
- server.groupname = "nobody"
- #压缩模块,压缩静态文件,减少文件下载流量
- deflate.enabled = "enable"
- deflate.compression-level = 5
- deflate.mem-level = 5
- deflate.window-size = 15
- deflate.allowed_encodings = ( "gzip", "deflate" )
- deflate.min-compress-size = 200
- deflate.work-block-size = 512
- deflate.mimetypes = ("text/html", "text/plain", "text/css", "image/gif", "image/jpeg", "text/javascript")
- #反向代理,转发数据到kerio web server
- $HTTP["host"] == "mail.xxx.com" {
- $HTTP["url"] =~ "^/" {
- proxy-core.protocol = "http"
- proxy-core.balancer = "static"
- proxy-core.backends = (
- "127.0.0.1:81"
- )
- proxy-core.max-pool-size = 16
- }
- #expire模块减少下载文件数量
- $HTTP["url"] =~ "\.(html|htm|jpg|gif|png|css|js)$" { expire.url = ( "" => "access 7 days" ) }
- }
复制代码 修改配置文件里的mail.xxx.com为你的域名。
启动lighttpd
lighttpd -f lighttpd.conf
然后就可以正常访问你的webmail了,看下,速度是不是快了N多。(第一次访问不会快,刷新一下页面就知道快很多了)
我机器没装PHOTOSHOP,我就不抓效果图上来了。
过段时间研究一下他的php看能否自己DIY一个,给动态程序加速,同时还可以提高安全性。
[ 本帖最后由 justkiding 于 2008-6-12 18:33 编辑 ] |
评分
-
查看全部评分
|