国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Apache > 正文

實例講解Apache+tomcat+ssl配置

2024-08-27 18:29:11
字體:
來源:轉載
供稿:網友

    我的運行環境: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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 百色市| 土默特右旗| 远安县| 吐鲁番市| 华容县| 合作市| 德令哈市| 台东县| 高要市| 浦江县| 平乡县| 和田县| 石家庄市| 台湾省| 咸阳市| 镇坪县| 安多县| 祁阳县| 琼中| 荃湾区| 道真| 碌曲县| 西吉县| 墨脱县| 改则县| 江津市| 四会市| 潞城市| 荃湾区| 南漳县| 讷河市| 兴海县| 郧西县| 承德县| 钟山县| 辰溪县| 逊克县| 连云港市| 寻乌县| 武平县| 呈贡县|