Quick tutorial on Apache + Tomcat + SSL Configuration

Source: Internet
Author: User
My runtime environment: Windows2003 Server SP4 + j2sdk1.5.0 + apache2.0.54 + tomcat5.5.9

Prepare software:

1. install Apache 2.0.54

2. Tomcat 5.5.14

3. JK2 connector (mod_jk2.so)

I. Configure Apache and tomcat

Apache is installed on D:/apache2 and listening port 80;

Tomcat is located at D:/tomcat51 and listening port 8080;

Both are installed using the Windows 2000 Service.

Copy mod_jk2.so to the Directory D:/apache2/modules:

1. Edit the D:/apache2/CONF/httpd. conf file and add:


       
        LoadModule jk2_module modules/mod_jk2.so
       

2. Change the adddefacharcharset ISO-8859-1 to adddefadefacharset gb2312 so that Apache automatically supports Chinese display;

3. Add in "VM configuration code segment": (this segment can be modified based on 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 it to the D:/apache2/conf directory. The content is as follows:


       
        # 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]

Compile a JSP file (sessiontest. JSP), put it in D:/tomcat51/webapps/JSP-examples. After restarting, start Apache and Tomcat and access http: // localhost/JSP-examples/sessiontest. JSP is accessible.

2. SSL steps for Tomcat configuration:

1. Generate server certificate server02.jks and client certificate DWP. p12

2. Put server02.jks In the conf directory and open the D:/tomcat51/CONF/server. xml file,

Modify the server. xml file, remove the comments of the commented content, and add the certificate storage location:


       
        <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"/>

Note: server02.jks is the certificate storage file.

Install the client certificate DWP. p12

3. Modify tomcat configuration to enable SSL automatically

Open the D:/test/tomcat51/webapps/JSP-examples/web_inf/Web. xml file and add the following content under the security-constraint label:


       
        
<User-data-constraint>
        
<Description>
Constrain the user data transport
For the whole application
</Description>
<Transport-guarantee>
Confidential
</Transport-guarantee>
</User-data-constraint>
Comment out the content under the <auth-constraint> label
<Auth-constraint>
<! -- Anyone with one of
Listed roles may access this area -->
<Role-Name> Tomcat </role-Name>
<Role-Name> role1 </role-Name>
</Auth-constraint>
Add the following content under the web-resource-collection Tag:
<URL-pattern>/* </url-pattern>

Restart Apache and tomcat,

Access http: // localhost/JSP-examples/sessiontest. jsp is accessed. This is

The system prompts the user to present the certificate and enable the SSL encryption channel. After SSL is established,

Returned results. The URL is changed to https: // localhost: 8443/JSP-examples/sessiontest. jsp.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.