The main configuration file of TOMCAT and the implementation summary of SSL

Source: Internet
Author: User
Tags openssl apache tomcat

The following are common tomcat configurations and issues

The following summary comes from practice (Os:ubuntu 10.10 64bit)

Directory Tomcat conf configuration tomcat-users.xml Configuration Web.xml static resource encoding setting URI encoding setting APR configuring SSL non-APR SSL configuration step APR environment's SSL configuration (SSL uses APR) gzip compressed JDBC Httpo Nly

Tomcat Home

Tomcat conf Configuration

tomcat-users.xml Configuration default is no user, so the development is not convenient, if it is a production environment, it is recommended to remove all users, development configuration (TOMCAT7) as follows: XML code <?xml version= ' 1.0 ' encoding= ' utf-8 '?> <tomcat-users> <role rolename= "Manager-gui"/> <role rolename= "Manager-scrip"  T "/> <role rolename=" manager-jmx "/> <role rolename=" manager-status "/> <user" admin " Password= "" "roles=" Manager-gui,manager-script,manager-jmx,manager-status "/> </tomcat-users> web.xml static State resource Encoding Settings

problem: in view of the page JS or CSS source code, there are garbled sources, but the page is all right, because Tomcat needs to configure the static resource encoding format to resolve: Open tomcat_home/conf/ Web.xml file, add code chartset=utf-8 information in Mime-type, such as:

XML code <mime-mapping> <extension>css</extension> <mime-type>text/css;charset= utf-8</mime-type> </mime-mapping> <mime-mapping> <extension>js</extension > <mime-type>text/javascript;charset=utf-8</mime-type> </mime-mapping> URI encoding Set up

problem: garbled problem, not through the form of submission, such as directly in the browser address bar directly input Chinese data garbled problem

Http://yoururl//your.action?name= my Chinese name &check= may be garbled on the server side

Resolve: Open the Tomcat_home/conf/server.xml file, set the Connector property uriencoding= "UTF-8" can be resolved, note that each connector to set this property

XML code <connector uriencoding= "UTF-8" port= "8159" protocol= "ajp/1.3" redirectport= "8593"/> APR

Tomcat prompt at startup--theAPR based Apache Tomcat Native Library which allows optimal performance in production environments is not found

Sep 3 8:59:51 PM org.apache.catalina.core.AprLifecycleListener init
info:the APR based Apache Tomcat Native Lib Rary which allows optimal performance in production environments is not found on the Java.library.path:/prog/java/jdk1.6 .0_20/bin:/prog/apache/app-apache-tomcat-7.0.0/bin
Sep 3, 8:59:51 PM Org.apache.catalina.startup.Catalina Load
info:initialization processed in 848 ms

steps: Apr details Prepare Dependency Package

Apr dependent: Apr 1.2+ Development Headers (Libapr1-dev package)

Download OpenSSL dependencies: OpenSSL 0.9.7+ Development Headers (Libssl-dev package) Decompression tomcat_home/bin/tomcat-native.tar.gz

Enter directory: tomcat-native-1.1.20-src/jni/native detailed installation See the building file in this directory to perform export JAVA_HOME=/PROG/JAVA/JDK set JDK execution:./ Configure--with-apr=/usr/bin--with-ssl=/usr/bin execution: Make

Execution: sudo make install--> installation to/usr/local/apr/lib execution: ln-s/usr/local/apr/lib/libtcnative-1.so $JAVA _home/jre/lib/ amd64/

Reboot Tomcat See:

Sep 3, 9:56:17 PM org.apache.catalina.core.AprLifecycleListener init
info:loaded APR based Apache Tomcat Native Library 1.1.20.
Sep 3, 9:56:18 PM org.apache.catalina.core.AprLifecycleListener init
info:apr Capabilities:ipv6 [true], SENDFI Le [true], accept filters [FALSE], random [true].
Sep 3, 9:56:18 PM org.apache.catalina.core.AprLifecycleListener lifecycleevent
info:failed to initialize the SS Lengine.
Sep 3 9:56:18 PM org.apache.coyote.http11.Http11AprProtocol init
info:initializing Coyote http/1.1 on http-878 2
Sep 3, 9:56:18 PM org.apache.coyote.ajp.AjpAprProtocol init
info:initializing Coyote ajp/1.3 on ajp-8711< C9/>sep 3 9:56:18 PM org.apache.catalina.startup.Catalina load
info:initialization processed in 840 ms

Configuring SSL

non-Apr SSL configuration steps

Create KeyStore:

Jdk/bin/keytool-genkey-keystore Tomcat.keystore-alias Tomcat-keyalg RSA
Put Tomcat.keystore into ${user.home} directory, is your user directory, of course, you can put in other directories

Modify Tomcat's Server.xml to add connector:

XML code <connector port= "9145" sslenabled= "true" scheme= "https" secure= "true" Clientauth= "false" sslprotocol= "TLS" uriencoding= "UTF-8" keystorefile= "${user.home}/tomcat.keystore" keystorepass= "cms4g-proxy-" PaSsWoRd "maxthreads="/> The SSL configuration of the APR environment (SSL does not use APR):

If you still want to configure SSL by following the # Non-Apr SSL configuration steps above, you need to do this:

Configuring Protocol=org.apache.coyote.http11.http11nioprotocol in Connector

        <connector port= "9145" sslenabled= "true" scheme= "https" secure= "true" Clientauth= "false" sslprotocol= "TLS"
                Protocol= "Org.apache.coyote.

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.