关于我们 广告服务 社区论坛
设为首页 加入收藏

行业新闻
服 务 器
模版下载
建站指南
冲浪宝典
办公软件
网站运营
操作系统
QQ 专题
网页制作
安全防御
视频教程
网络编程
SEO专区
软件下载
图像设计
Cisco
网页特效
Wap 技术
联盟赚钱
网页素材
 首页 | 企业建站 | 网页制作 | 网站运营 | 网络编程 | 图像设计 | 冲浪宝典 | 操作系统 | SEO专区 | 联盟赚钱 | Cisco

欢迎来到e天下网络首页>>网络编程>>JSP>>正文|实例讲解Apache+tomcat+ssl配置

实例讲解Apache+tomcat+ssl配置

[ 来路:21kn.com    时间:2007-7-8 15:58:52    点击: ]

 

    我的运行环境:Windows2003 Server SP4 + J2SDK1.5.0 + Apache2.0.54 + Tomcat5.5.9

    **准备软件:
    1、安装 Apache 2.0.54
    2、Tomcat 5.5.14
    3、Jk2连接器(mod_jk2.so)
 
    一:配置Apache和tomcat

    Apache安装在d:\Apache2 下,监听端口 80;
    Tomcat在D:\Tomcat51 下,监听端口 8080;
    两者都以windows 2000服务进行安装。

    将mod_jk2.so复制到d:\Apache2\modules目录下:
 
    1.编辑d:\Apache2\conf\httpd.conf文件,在LoadModule那一段代码中添加:
    LoadModule jk2_module modules/mod_jk2.so
 
    2.将AddDefaultCharset ISO-8859-1 改为 AddDefaultCharset GB2312 使Apache自动支持中文显示;
 
    3.在“虚拟主机配置代码段”中添加:(此段配置可以根据你的实际情况进行修改)
  <VirtualHost *:80>
    ServerAdmin linvsfen◎163.com
    DocumentRoot "d:/ Tomcat51/webapps/jsp-examples
    ServerName localhost
    ErrorLog logs/error_log
    CustomLog logs/access_log common
  </VirtualHost>

    **编写workers2.properties文件并加入d:\Apache2\conf目录,内容如下:
   
  # Usually commented out on production environments
[logger.apache2]
file=”D:/Apache2/logs/error.log”
level=ERROR
# Provide the basic config needed
[config]
file=D:/Apache2/conf/workers2.properties
debug=1
# Provide the location of shm file on the Apache web server
[shm]
file=D:/Apache2/conf/jk2.shm
size=1000000

[channel.socket:localhost:8009]
port=8009
host=localhost
#define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
# Map the Tomcat examples webapp to the Web server uri space
[uri:/jsp-examples/*]
[uri:/*.jsp]

    **编写一个jsp文件(sessiontest.jsp),放在d:\Tomcat51\webapps\jsp-examples 下;

    重新启动以后,启动apache和tomcat,访问http://localhost/jsp-examples/sessiontest.jsp可以访问。

    二.Tomcat配置上ssl步骤:

    1.    生成服务器证书server02.jks和客户端证书dwp.p12

    2、把server02.jks放到conf目录下,

    打开d:\ tomcat51\conf\server.xml 文件,
    然后修改server.xml文件,将注释掉的内容的注释去掉和增加证书存放的位置:如下:
<Connector     port="8443" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" scheme="https" secure="true"
               clientAuth="true" sslProtocol="TLS"
               keystoreFile="conf\server02.jks"     keystorePass="123456"
              truststoreFile="conf\server02.jks" truststorePass="123456"/>
    注:server02.jks是证书存贮文件

    3. 安装客户端证书dwp.p12

    3. 修改Tomcat配置,使其自动启用SSL
   
    打开d:\test\tomcat51\webapps\jsp-examples\WEB_INF\web.xml 文件,在security-constraint 标签下,增加如下内容:
    <user-data-constraint>
      <description>
         Constrain the user data transport for the whole application
      </description>
      <transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
 注释掉<auth-constraint>标签下的内容
<auth-constraint>
         <!-- Anyone with one of the listed roles may access this area -->
         <role-name>tomcat</role-name>
     <role-name>role1</role-name>
      </auth-constraint>
在web-resource-collection 标签下,增加如下内容:
      <url-pattern>/*</url-pattern>
    重新启动Apache和tomcat,
 
    访问 http://localhost/jsp-examples/sessiontest.jsp是可是访问的,这是系统提示用户出示证书,启用SSL加密通道,SSL建立后,返回结果。URL变为https://localhost:8443/jsp-examples/sessiontest.jsp

::::站长友情提示:多花一分钟学点什么都好::::

 

上一篇:JFC/Swing活学活用之JLabel文字魔法  下一篇:使用AJAX和J2EE创建功能强大的瘦客户端

 ::热点信息::

 

= = 免责声明 = =

① 欢迎转载我网所刊信息,请注明“来源:E天下网络”。
② 凡本网注明“来源:XXX(非E天下网络)”的作品,均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如因作品内容、版权和其它问题需要同本网联系的,请在30日内进行。
※联系方式:Airtofly@163.com

::推荐文章::

 

ASP教程:详细学习ASP的内置对象

::图像设计::

 

动态图片搜索家——GIF RUNN
软件搜索利器——FileFerret
实例说明构图要讲规律
Character Builder让你尽展靓
全景图速成者Cool360
三维模型速成工具——Canoma
剪贴专家SmartBoard 32
新世纪的图像处理利器——Ph
更多内容..

 

 

关于我们 广告服务 友情链接 合作伙伴 社区论坛 免责声明

Copyright © 2007   21kn.com Inc. All rights reserved.e天下网络工作室

网站白天客服QQ:26875416 (非24小时)  合作QQ:597004688    粤ICP备06026423号