WebSphere下配置HTTP压缩
背景
WebSphere本身的安装配置中并不包含HTTP压缩的模块,而是通过新增WebServer来实现的,WebSphere通过Plugin与WebServer进行通信,所有的HTTP请求通过WebServer来转发。WebServer上面可以实现请求过滤,内容压缩,以及负载均衡等功能。
WebServer通常可以是IIS(Internet Information Service),更常用的是IHS(IBM HTTP Server),本文以IHS为例。IHS本身是基于Apache Web Server进行的扩展,所以基本配置和Apache是一致的。
1 Installer
- 获取 IBM HTTP Server (IHS) 安装包,from C1G2KML.zip
- Unzip and run the launchpad.exe
2 Install IHS and WebSphere Plugin
- 运行后选择 IBM HTTP Server Installation
- 点击 Next 并选择IHS的安装路径, for example C:IBMHTTPServer
- 设置 HTTP Port 和 Administration port (保持默认值即可)
- 输入IHS管理员的用户名和密码,一般选择用本地系统用户登录启动即可,然后点击"Next" (For Admin Account, we can setup later, so can choose "Log on as a local system account"in this step.)
- HTTP Administration Server Authentication, input admin account like admin/admin in this step. 在这一步中输入admin的用户名密码,如 admin/admin
- IBM HTTP Server Plug-in for IBM WebSphere Application Server, input Web Server name like 'webserverIHS' or just use the default one. 指定Web服务器的名称,比如'webserverIHS' ,这个名称会在WebSphere的Admin Console的Web Servers页面中显示
- Click Next to Finish
- Copy the configure WebServer batch file (Example: configurewebserverIHS.bat,这个文件的名字后缀与前面指定的WebServer的名称是一致的) fromC:IBMHTTPServerPluginsin to WebSphere App Server bin folder (Example:C:IBMWebSphereAppServerin,注意是AppServer下面的bin目录,而非profiles/AppSrv01/bin目录)
- Run the configure WebServer batch file in WebSphere App Server bin folder. 运行这个配置脚本,会自动把IHS和WebSphere进行关联集成,可以通过访问IHS的端口来访问WebSphere安装的应用程序。
3 Setup HTTP Compression
Refer to Enabling Compression on IBM HTTP Server
- 打开 httpd.conf 文件,位于 C:IBMHTTPServerconf 文件夹, 确保 LoadModule deflate_module 模块的注释已经去掉。
- 增加mod_deflate的配置 <IfModule mod_deflate.c> ,并加入对指定内容类型做过滤的Output Filter 。
- Examples like below
LoadModule deflate_module modules/mod_deflate.so <IfModule mod_deflate.c> DeflateFilterNote Input instream DeflateFilterNote Output outstream DeflateFilterNote Ratio ratio LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate CustomLog C:IBMHTTPServerlogsdeflate.log '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' <Location / > AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE text/plain text/xml AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE text/css text/javascript AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/atom+xml AddOutputFilterByType DEFLATE text/javascript # Insert filter SetOutputFilter DEFLATE # Don't compress images or binaries SetEnvIfNoCase Request_URI \.(?:gif|[jm]pe?g|png|t?gz|bz2*|zip|exe|iso|avi|swf)$ no-gzip dont-vary </Location> </IfModule>
4 Trouble Shooting
- Forget the admin password
Use below command to setup admin account
C:IBMHTTPServerin>htpasswd C:/IBM/HTTPServer/conf/admin.passwd admin
- Failed to startup IHS on Windows
Refer to scenarios of Experiencing an IBM HTTP Server Service logon failure on Windows operating systems