tomcat從 http轉成https,並且去掉埠號
強制使用HTTPS方式訪問Tomcat中的相關專案,於是研究了下,現將具體的步驟寫下:
主要分2步:讓tomcat能使用https--->強制使用https訪問
1.讓tomcat能使用https
A.在執行命令JAVA_HOME/bin/keytool -genkey -alias tomcat-keyalg
RSA -keystore C:\Tomcat\GMAE3.0Tomcat\tomcat.keystore
這樣就生成了證照,將證照放到合適的地方(任意地方都可以)
B.開啟tomcat目錄下的server.xml檔案並找到關於ssl的相關段
Java程式碼
1. <!-- Define a SSL HTTP/1.1 Connector on port 8443
2. This connector uses the JSSE configuration, when using APR, the
3. connector should be using the OpenSSL style configuration
4. described in the APR documentation -->
5. <!--<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
6. maxThreads="150" scheme="https" secure="true"
7. clientAuth="false" sslProtocol="TLS" />-->
C.去掉註釋,添keystoreFile="C:\Tomcat\GMAE3.0Tomcat\tomcat.keystore"
keystorePass="tomcat"的屬性
改動完成後配置為:
Java程式碼
1. <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" keystoreFile="C:\Tomcat\GMAE3.0Tomcat\tomcat.keystore" keystorePass="tomcat" sslProtocol="TLS" />
D. 若想同時去掉8443埠號,將上述配置的8443改成443:
Java程式碼
1.
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" keystoreFile="C:\Tomcat\GMAE3.0Tomcat\tomcat.keystore" keystorePass="tomcat" sslProtocol="TLS" />
另外將
Java程式碼
1. <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000"redirectPort="8443" URIEncoding="UTF-8"/>
改成
Java程式碼
1. <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000"redirectPort="443" URIEncoding="UTF-8"/>
這樣使用者也可以去掉埠同時訪問http和https了
E.然後重啟tomcat就能使用HTTPS訪問
2.強制https訪問
在tomcat\conf\web.xml中的</welcome-file-list>後面加上這樣一段:
Java程式碼
1. <login-config>
2. <!-- Authorization setting for SSL -->
3. <auth-method>CLIENT-CERT</auth-method>
4. <realm-name>Client Cert Users-only Area</realm-name>
5. </login-config>
6. <security-constraint>
7. <!-- Authorization setting for SSL -->
8. <web-resource-collection >
9. <web-resource-name >SSL</web-resource-name>
10. <url-pattern>/*</url-pattern>
11. </web-resource-collection>
12. <user-data-constraint>
13. <transport-guarantee>CONFIDENTIAL</transport-guarantee>
14. </user-data-constraint>
15. </security-constraint>
完成以上步驟後,在瀏覽器中輸入http的訪問地址也會自動轉換為https了。
相關文章
- 如何把HTTP轉成HTTPS?HTTP
- ios網路協議從http變成httpsiOS協議HTTP
- 從HTTP到HTTPSHTTP
- Netweaver的埠號和Spring boot內嵌的Tomcat埠Spring BootTomcat
- 阿里雲配置http轉https阿里HTTP
- 如何解決Tomcat埠號被佔用Tomcat
- liunx下檢視tomcat佔用的埠號Tomcat
- 如何將自己的網站從 HTTP 的轉換為 HTTPS 的網站HTTP
- 直播app原始碼,全屏並且去掉底部虛擬導航欄APP原始碼
- 圖片在瀏覽器上從http變成https問題的解決方案瀏覽器HTTP
- NGINX使用rewrite實現http 跳轉 httpsNginxHTTP
- 從http到https你可以這樣做HTTP
- nginx開啟ssl並把http重定向到httpsNginxHTTP
- http,https, http2.0HTTP
- Nginx配置正向代理支援HTTP和HTTPS轉發NginxHTTP
- 如何設定HTTP自動跳轉到HTTPSHTTP
- tomcat跳轉到自己的servlet,網頁一直載入,並且會彈出自己的eclipseTomcatServlet網頁Eclipse
- HTTP 和 HTTPSHTTP
- HTTP和HTTPSHTTP
- HTTPS和HTTPHTTP
- 生成二維碼,並且儲存,指定位置的view成圖片,並且儲存到本地相簿View
- HTTP與HTTPS:為什麼HTTPS比HTTP更安全?HTTP
- nginx + https(tomcat2)NginxHTTPTomcat
- 解決tomcat埠占用Tomcat
- USB轉re232轉換器(串列埠線)裝置出現感嘆號且裝置管理器下的埠沒有出現,解決辦法串列埠
- SSL:http與httpsHTTP
- 學習HTTP——HTTPSHTTP
- 恆訊科技教你:http怎麼直接跳轉到https?HTTP
- css文字超出2行就隱藏並且顯示省略號CSS
- table表格細線且去掉外邊框效果
- vim介面去掉^M符號符號
- sra 資料轉成 fastq並改名AST
- 比較簡單實用並且免費的埠對映(內網穿透)工具內網穿透
- HTTP和HTTPS詳解HTTP
- Http與Https協議HTTP協議
- http怎麼改成httpsHTTP
- [深入17] HTTP 和 HTTPSHTTP
- HTTP和HTTPS協議HTTP協議
- HTTP 與 HTTPS 簡介HTTP