Operating environment: Windows2003 Server SP4 + j2sdk1.5.0 + Apache2.0.54 + Tomcat5.5.9
To prepare the software:
1. Install Apache 2.0.54
2.Tomcat 5.5.14
3.JK2 Connector (mod_jk2.so)
first, configure Apache and Tomcat
Apache installed under D:/apache2, listening on port 80;
Tomcat under D:/TOMCAT51, listening on port 8080;
Both are installed with Windows 2000 service.
Copy the mod_jk2.so to the D:/apache2/modules directory:
1. Edit the d:/apache2/conf/httpd.conf file and add it to the LoadModule section of the code:
LoadModule Jk2_module modules/mod_jk2.so
2. Change the Adddefaultcharset iso-8859-1 to Adddefaultcharset GB2312 so that Apache automatically supports Chinese display;
3. Add in "Virtual Host Configuration Snippet": (This configuration can be modified according to your actual situation)
<virtualhost *:80>
ServerAdmin linvsfen 163.com documentroot "d:/ Tomcat51/webapps/jsp-examples
ServerName localhost ErrorLog logs/error_log
customlog logs/access_log Common </VirtualHost> |
Write the Workers2.properties file and add the d:/apache2/conf directory, which reads as follows:
# usually commented out onproduction environments[logger.apache2]file= "
d:/apache2/logs/error.log" level=ERROR# Provide the basic config Needed[config]
file=d:/apache2/conf/workers2.propertiesdebug=1# provide the location of SHM file on the
Apache web server[shm]file=d:/apache2/conf/jk2.shmsize=1000000
[channel.socket:localhost : 8009]port=8009host=localhost#define the worker
[ajp13:localhost:8009]channel=channel.socket:localhost:8009# Map the Tomcat
examples WebApp to the WEB server URI spaces [uri:/jsp-examples/*][uri:/*.jsp] |
Write a JSP file (sessiontest.jsp), put it under D:/tomcat51/webapps/jsp-examples, start Apache and Tomcat after reboot, and access http://localhost/ jsp-examples/sessiontest.jsp can be accessed.
Second, the Tomcat configuration on the SSL step:
1. Generate server certificate Server02.jks and client certificates DWP.P12
2. Put the Server02.jks in the Conf directory, open the d:/tomcat51/conf/server.xml file,
The Server.xml file is then modified to remove comments from the annotated contents and to increase the location of the certificate deposit: as follows:
<connector port= "8443" maxhttpheadersize= 8192 "maxthreads=" minsparethreads= "75" maxsparethreads= "
Enablelookups= "false" disableuploadtimeout= "true" acceptcount= "MB"
scheme= "https" secure= "true" clientauth= " True "sslprotocol=" TLS "
keystorefile=" Conf/server02.jks "
keystorepass=" 123456 "truststorefile=" conf/ Server02.jks "
truststorepass=" 123456 "/> |
Note: Server02.jks is a certificate storage file
Install the client certificate DWP.P12
3. Modify the Tomcat configuration so that it automatically enables SSL
Open the D:/test/tomcat51/webapps/jsp-examples/web_inf/web.xml file, and under the Security-constraint tab, add the following:
<user-data-constraint>
<description>
Constrain the user data transport for the whole application
</description>
<transport-guarantee> Confidential </transport-guarantee>
</ User-data-constraint>
<!--comment out <auth-constraint> label content-->
<auth-constraint>
<!--Anyone with one of the listed roles could access this area-->
<role-name>tomcat</role-name>
<role-name>role1</role-name>
</auth-constraint>
<!--in web-resource-collection tag, add the following content:-->
<url-pattern>/*</url-pattern>
|
Restart Apache and Tomcat, Access http://localhost/jsp-examples/sessiontest.jsp is accessible, this is the system prompts the user to produce a certificate, enable SSL encryption channel, SSL is established, return the result. URL becomes https://localhost:8443/jsp-examples/sessiontest.jsp