tomcat uses both http and https access configuration methods
- 2020-12-07 04:37:47
- OfStack
For some items in tomcat need to use ssl encryption and some can be accessed directly, it can be achieved by modifying server.xml under tomcat/conf. The detailed configuration can be referred to the following code, note < Service name Catalina1 = "" > The configuration in this TAB.
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<!-- The use of ssl Configuration, required https To access -->
<Connector port="8284" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"
clientAuth="false" sslProtocol="TLS"
SSLEnabled="true" scheme="https" secure="true"
keystoreFile="conf/tomcat.jks" keystorePass="pico2012server"
truststoreFile="conf/tomcat.jks" truststorePass="pico2012server"
/>
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
<!-- join 1 A new web service configuration for each service Can be configured separately project load directory, port, and so on -->
<Service name="Catalina1">
<!-- This indicates that the loaded project still uses the original http Access to -->
<Connector port="8484" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"
/>
<Connector port="18009" protocol="AJP/1.3" redirectPort="18443" />
<Engine name="Catalina1" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<!-- the service Load the project place directory, with webapps With the directory webapps1 -->
<Host name="localhost" appBase="webapps1"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<!-- The specified load to be shown here webapps1 Under the GS-Web engineering -->
<Context path="" docBase="GS-Web" debug="0" reloadable="true"/>
</Host>
</Engine>
</Service>
</Server>