邮件服务器-邮件系统-邮件技术论坛(BBS)
标题:
给kerio webmail加速!
[打印本页]
作者:
justkiding
时间:
2008-6-12 18:32
标题:
给kerio webmail加速!
为了感谢斑竹和各位的帮忙,我也分享一点小经验。
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 编辑
]
作者:
tdk
时间:
2008-6-12 23:31
需要这样的兄弟!
感谢分享经验!
众人拾柴火焰高!
作者:
garywang
时间:
2008-6-13 13:18
按我的理解,是不是给配置一个proxy,给webmail,这样会因为缓存就快很多 ?
作者:
justkiding
时间:
2008-6-14 11:14
1、缓存,开一个反向代理。
2、压缩,用web server的压缩模块压缩。
你用个http sniffer抓包就可以发现kms webmail占用下载时间多的地方了。
[
本帖最后由 justkiding 于 2008-6-14 11:15 编辑
]
作者:
garywang
时间:
2008-6-16 08:44
这是一个好方法,那些公共的邮件系统应该都这么样使用的。
不过存在一些不足,因为不可能像公共邮件系统那样投入,多了个proxy,就多了一些风险。
最好能在他的php上做些什么优化或简化。
作者:
justkiding
时间:
2008-6-16 14:40
kms的php我搞不定
我想了两个办法修改他的PHP参数
1、改他的php.ini,不行,kms启动的时候会重写php.ini,如果写入失败,则载入默认的php参数。
2、使用.htaccess,还是不行,不知道为什么……可能php模块不是在apache上面跑的导致的。
作者:
tdk
时间:
2008-6-16 14:56
我也曾经实验过,
感觉kerio自己的引擎加入了更多的参数处理 不是单纯的apache封装
作者:
justkiding
时间:
2008-6-16 15:28
'./configure' '--with-tsrm-pthreads' '--enable-maintainer-zts' '--without-mysql' '--without-sqlite' '--without-pdo-sqlite' '--enable-embed=static' '--enable-mbstring=shared' '--with-libxml-dir=/Autobuild/Builds/KMS-5340-XSImpQS/autobuild/BUILD/libs/common/external' '--prefix=/Autobuild/Builds/KMS-5340-XSImpQS/autobuild/BUILD/libs/common/external'
复制代码
kerio
Kerio plugin utils
:-)
kerio_utils
Kerio MailServer utilities
:-)
作者:
justkiding
时间:
2008-6-16 15:29
我看了他的phpinfo的输出,禁用了不少危险函数,加入了他自己的扩展。
所以自己编译一套apache php是无法跑起来的。
欢迎光临 邮件服务器-邮件系统-邮件技术论坛(BBS) (http://bbs.5dmail.net/)
Powered by Discuz! X3.2