tomcat同時(shí)使用http和https訪問(wèn)的配置方法
針對(duì)一個(gè)tomcat中有的項(xiàng)目需要使用ssl加密有些可以直接訪問(wèn)的情況,可通過(guò)修改tomcat/conf下的server.xml來(lái)實(shí)現(xiàn)。具體配置可參考下面這段代碼,注意<Service name=”Catalina1″>這個(gè)標(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才可訪問(wèn) -->
<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>
<!-- 加入一個(gè)新的網(wǎng)站服務(wù)配置,每個(gè)service都可以單獨(dú)配置工程加載目錄、端口等 -->
<Service name="Catalina1">
<!-- 此處表示加載的工程仍使用原始的http方式訪問(wèn) -->
<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>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Web應(yīng)用中設(shè)置Context Path案例詳解
這篇文章主要介紹了Web應(yīng)用中設(shè)置Context Path案例詳解,本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-08-08
Windows下搭建Tomcat HTTP服務(wù)并發(fā)布外網(wǎng)遠(yuǎn)程訪問(wèn)
本文主要介紹了Windows下搭建Tomcat HTTP服務(wù)并發(fā)布外網(wǎng)遠(yuǎn)程訪問(wèn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-05-05
TomCat啟動(dòng)找不到配置的環(huán)境變量解決
本文主要介紹了TomCat啟動(dòng)找不到配置的環(huán)境變量解決,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2024-12-12
tomcat設(shè)置自啟動(dòng)的方法實(shí)現(xiàn)
本文主要介紹了在不同操作系統(tǒng)(Windows、MacOS、Ubuntu/Linux)下設(shè)置Tomcat自啟動(dòng)服務(wù),具有一定的參考價(jià)值,感興趣的可以了解一下2025-03-03
IDEA中Tomcat在控制臺(tái)亂碼問(wèn)題及IDEA編碼設(shè)置UTF-8的方法
這篇文章主要介紹了IDEA中Tomcat在控制臺(tái)亂碼問(wèn)題及IDEA編碼設(shè)置UTF-8的操作方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-07-07
Tomcat簡(jiǎn)單網(wǎng)站部署的三種方式小結(jié)
本文主要介紹了Tomcat簡(jiǎn)單網(wǎng)站部署的三種方式小結(jié),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-05-05
Tomcat 多站點(diǎn)配置詳解及實(shí)現(xiàn)方法
這篇文章主要介紹了Tomcat 多站點(diǎn)配置詳解及實(shí)現(xiàn)方法的相關(guān)資料,需要的朋友可以參考下2016-12-12

