tomcat同時使用http和https訪問的配置方法
更新時間:2018年07月09日 10:03:57 作者:loading
這篇文章主要介紹了tomcat同時使用http和https訪問的配置方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
針對一個tomcat中有的項目需要使用ssl加密有些可以直接訪問的情況,可通過修改tomcat/conf下的server.xml來實現(xiàn)。具體配置可參考下面這段代碼,注意<Service name=”Catalina1″>這個標(biāo)簽中的配置。
<?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"> <!-- 此處使用了ssl配置,需用https才可訪問 --> <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> <!-- 加入一個新的網(wǎng)站服務(wù)配置,每個service都可以單獨配置工程加載目錄、端口等 --> <Service name="Catalina1"> <!-- 此處表示加載的工程仍使用原始的http方式訪問 --> <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> <!-- 該service加載的工程放置目錄,與webapps同目錄的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" /> <!-- 此處要顯示的指定加載webapps1下的GS-Web工程 --> <Context path="" docBase="GS-Web" debug="0" reloadable="true"/> </Host> </Engine> </Service> </Server>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
解決tomcat出現(xiàn):java.lang.IllegalStateException:無輸出目錄問題
這篇文章主要介紹了解決tomcat出現(xiàn):java.lang.IllegalStateException:無輸出目錄問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-01-01Tomcat之web應(yīng)用的目錄組成結(jié)構(gòu)_動力節(jié)點Java學(xué)院整理
這篇文章主要介紹了Tomcat之web應(yīng)用的目錄組成結(jié)構(gòu),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-07-07解決Tomcat 中catalina.out持續(xù)累加問題
這篇文章主要介紹了解決Tomcat 中catalina.out持續(xù)累加問題 ,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2018-03-03