分四部分
1。应用目标和环境
2。apache2 weblogic openssl安装
3。虚拟主机的配置
4。补遗或注解
一. 应用目标和环境
应用目标
1。jsp支持的webserver,只有一个ip,多个虚拟主机,其中有一个支持ssl的虚拟主机。
应用环境
1. os 为 solaris 9 和建议补丁
2. weblogic为8.1sp4 ,java为 1.4.1_06-b01
3. OpenSSL 0.9.7g
4. apache 2.0.54
二. apache2 weblogic openssl安装
1. apache 2.0.54的安装
略
2. weblogic 8.1 sp4的安装
略
3. openssl的安装
略
三. 虚拟主机的配置
1. 需要配置的虚拟主机
www 网站
bbs 论坛
diy 后台及个人管理维护平台
ssl 提供https传输的虚拟主机
2. 虚拟主机使用的ip
192.168.1.254
3. httpd.conf中的相关配置
......
ServerName [url]www.testmysite.com.cn[/url]
ServerRoot "/usr/local/apache2"
Listen 80
<IfDefine SSL>
LoadModule ssl_module modules/mod_ssl.so
</IfDefine>
# support weblogic
LoadModule weblogic_module modules/mod_wl_20.so
#
# load ssl.conf
<IfModule mod_ssl.c>
Include conf/ssl.conf
</IfModule>
#
# load VirtualHost
Include "conf/vhost.conf"
#
......
SSLRandomSeed connect builtin
<IfDefine SSL>
#
Listen 443
#
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
#
SSLPassPhraseDialog builtin
#
SSLMutex default
</IfDefine>
#
NameVirtualHost 192.168.1.254:80
#
# Section 1: http virtualhost
<VirtualHost 192.168.1.254:80>
ServerAdmin [email]webmaster@testmysite.com[/email]
DocumentRoot "/web/webapp"
ServerName [url]www.testmysite.com[/url]
ErrorLog logs/testmysite-error_log
AddType application/x-httpd-php .php
AddType text/html .shtml
CustomLog logs/testmysite-access_log combined
TransferLog logs/testmysite-access_log
<IfModule mod_weblogic.c>
WebLogicHost 192.168.1.254
WebLogicPort 7001
MatchExpression *.jsp
MatchExpression *.do
MatchExpression *.jspa
MatchExpression /myhome/*
</IfModule>
<Directory "/web/webapp">
#php_flag engine on
Options FollowSymLinks MultiViews Includes
AddOutputFilter Includes .shtml
AddOutputFilter Includes .php
AllowOverride None
Allow from all
</Directory>
<Directory "/web/webapp/WEB-INF">
Order deny,allow
Deny from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.1.254:80>
ServerAdmin [email]webmaster@testmysite.com[/email]
DocumentRoot "/web/bbs"
ServerName bbs.testmysite.com
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog logs/bbs-access_log combined
ServerName bbs.testmysite.com
ServerAlias diy
ErrorLog logs/bbs-error_log
TransferLog logs/bbs-access_log
<IfModule mod_weblogic.c>
WebLogicHost 192.168.1.254
WebLogicPort 7001
MatchExpression *.jsp
MatchExpression *.jspa
MatchExpression *.do
</IfModule>
<Directory "/web/bbs">
Options FollowSymLinks MultiViews Includes
AddOutputFilter Includes html
AllowOverride None
Allow from all
</Directory>
<Directory "/web/bbs/WEB-INF">
Order deny,allow
Deny from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.1.254:80>
ServerAdmin [email]webmaster@testmysite.com[/email]
DocumentRoot "/web/diy"
ServerName diy.testmysite.com
ErrorLog logs/diy-error_log
TransferLog logs/diy-access_log
<IfModule mod_weblogic.c>
WebLogicHost 192.168.1.254
WebLogicPort 7001
MatchExpression *.jsp
MatchExpression *.jspa
MatchExpression *.do
</IfModule>
<Directory "/web/diy">
Options FollowSymLinks MultiViews Includes
AddOutputFilter Includes html
AllowOverride None
Allow from all
</Directory>
<Directory "/web/diy/WEB-INF">
Order deny,allow
Deny from all
</Directory>
</VirtualHost>
# Section 2: https VirtualHost
<VirtualHost 192.168.1.254:443>
ServerName ssl.testmysite.com
DocumentRoot "/web/ssl"
CustomLog logs/ssl-access_log common
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile conf/ssl.crt/server.crt
SSLCertificateKeyFile conf/ssl.key/server.key
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
SSLOptions +StdEnvVars
</Files>
<Directory "/web/ssl">
SSLOptions +StdEnvVars
</Directory>
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
<IfModule mod_weblogic.c>
WebLogicHost 192.168.1.254
WebLogicPort 7001
MatchExpression *.jsp
MatchExpression *.do
MatchExpression *.jspa
MatchExpression /myhome/*
</IfModule>
<Directory "/web/ssl">
Options FollowSymLinks MultiViews Includes
AddOutputFilter Includes .shtml
AddOutputFilter Includes .php
AllowOverride None
Allow from all
</Directory>
<Directory "/web/webapp/WEB-INF">
Order deny,allow
Deny from all
</Directory>
</VirtualHost>
6.1 SSLEngine on
在虚拟主机中打开ssl支持,默认主服务主机和虚拟主机是禁用的。
6.2 SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
ssl协议握手协商时使用的密码簇,支持所有握手密码
6.3 SSLCertificateFile conf/ssl.crt/server.crt
服务器端PEM-encoded X.509认证文件
6.4 SSLCertificateKeyFile conf/ssl.key/server.key
服务器端PEM-encoded私匙文件
6.5 SSLOptions +StdEnvVars
配置各种运行时的SSL引擎选项, +StdEnvVars创建SSL与CGI&SSI相关的变量,仅用在CGI和SSI的页面中。
四. 补遗或注解
1. 认证文件的认证方式
本例中采用的自认证的方式,就是说没有去购买证书,如果是商业站点可以考虑购买证书。
2. 自认证文件的生成
a. 生成private Key文件
openssl genrsa -des3 -out server.key 1024
b. 创建服务器端的认证文件
openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out server.crt
在提示输入common name的时候输入域名:www.testmysite.com
c. 按照vhost.conf中的配置,存放b步骤中创建的文件
3. apache的启动和关闭方式(SSL)
3.1 启动
./apachectl startssl
会提示输入创建server.key时的密码,输入正确才能启动
3.2 关闭
./apachectl stop
3.3 为了测试方便可以关闭启动时输入密码
a. 修改vhost.conf
#SSLCertificateKeyFile conf/ssl.key/server.key
SSLCertificateKeyFile conf/ssl.key/server.key.unsecure
b. server.key.unsecure的生成
openssl rsa -in server.key -out server.key.unsecure
4. ssl仅支持基于ip的虚拟主机
文章来源于领测软件测试网 https://www.ltesting.net/
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073