Tomcat的HTTPS配置及HTTP自动跳转配置
1.生成证书
(1)在jdk的安装目录\bin\keytool.exe下打开keytool.exe

在命令行中输入以下命令:
keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore "E:\tomcat.keystore" -validity 36500

以上命令将生产一对非对称密钥和自我签名的证书E:\tomcat.keystore
注意:“名字与姓氏”应该是域名,输成了姓名,和真正运行的时候域名不符,会出问题
这里我输入的密码是123456, 域名是以tomcat为例, 省市以广东深圳为例
2. 配置tomcat服务器
定位到tomcat服务器的安装目录, 找到conf下的server.xml文件

找到如下已经被注释的代码:

<!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" />
-->
去掉注释,修改为:
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="E:\tomcat.keystore"
keystorePass="123456" />

在互联网上, http协议的默认端口是80, https的默认端口是443, 这里将端口改为了443
3.HTTP自动跳转配置
配置Tomcat,打开$CATALINA_HOME/conf/server.xml,修改如下
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
修改为
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
<!--
<Connector port="8009" enableLookups="false" protocol="AJP/1.3" redirectPort="8443" />
-->
修改为:
<Connector port="8009" enableLookups="false" protocol="AJP/1.3" redirectPort="443" />
在tomcat\conf\web.xml中的</welcome-file-list>后面加上这样一段
<login-config>
<!-- Authorization setting for SSL -->
<auth-method>CLIENT-CERT</auth-method>
<realm-name>Client Cert Users-only Area</realm-name>
</login-config>
<security-constraint>
<!-- Authorization setting for SSL -->
<web-resource-collection >
<web-resource-name >SSL</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>

Tomcat的HTTPS配置及HTTP自动跳转配置的更多相关文章
- Tomcat的Https设置及Http自动跳转Https
Https相关介绍 Https是由NetScape公司设计的一个基于Http的加密传输协议,可以这样理解Https = Http +SSL(安全套接层),Https的端口为443,而且还需要申请 ...
- mybatis generator配置,Mybatis自动生成文件配置,Mybatis自动生成实体Bean配置
mybatis generator配置,Mybatis自动生成文件配置,Mybatis自动生成实体Bean配置 ============================== 蕃薯耀 2018年3月14 ...
- nginx配置http访问自动跳转到https
1.按照如下格式修改nginx.conf 配置文件,80端口会自动转给443端口,这样就强制使用SSL证书加密了.访问http的时候会自动跳转到https上面 server { listen ; se ...
- IIS7多站点ssl配置及http自动跳转到https
SSL证书配置参考如下: http转https实战教程iis7.5 window08 IIS7安装多域名SSL证书绑定443端口 关键是修改C:\Windows\System32\inetsrv\co ...
- Tomcat配置https及访问http自动跳转至https
https介绍: HTTPS(全称:Hypertext Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全 ...
- Tomcat配置https、访问http自动跳转至https
1.配置Tomcat,打开$CATALINA_HOME/conf/server.xml,修改如下 <Connector port="8080" protocol=" ...
- nginx配置https并强制http自动跳转到https
关于使用HTTPS/SSL的必要性,可以自行baidu,援引的说法,EFF(Electronic Frontier Foundation),全球过半流量采用https. https://www.osc ...
- Charles 抓包发现自动跳转为https 问题梳理
今天遇到个有点意思的问题.特此记录. 业务场景: 做了一个页面,但是对外是挂载在京东主站上.如:www.jd.com/yifu/123456.html. 现场情况: 在本地/测试环境/预发环境中,每次 ...
- tomcat设置http自动跳转为https访问
一.生成服务器端证书文件 可以使用Windows系统或者Linux系统 (1)Windows环境 条件:已经安装JDK 步骤: 1.在运行里输入cmd进入命令窗口 2.进入JDK安装目录 如D:/P ...
随机推荐
- [PY3]——内置数据结构(5)——字符串编码
py2和py3中关于字符串的最大区别? python2中只有 unicode类型 而python3中有 string bytes两种类型 关于string和bytes的区分? 1.str是文本序列.b ...
- (三)JNI常用示例
针对我之前文章的练习:JNI方法总结 1. 字符串 JAVA层: test.testString("HELLOWORLD"); JNI层: JNIEXPORT jstring JN ...
- ListView和Adapter
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools= ...
- Nginx proxy buffer相关的设置和解释
proxy_buffer_size 4k; proxy_buffering on;proxy_buffers 4 4k;proxy_busy_buffers_size 8k;proxy_max_tem ...
- IIS 站点 共享目录
1.先建立站点,再设置文件夹为共享,Everyone 2.Mac电脑 Everyone不能访问,必须建立用户
- Python——爬虫学习1
爬虫了解一下 网络爬虫(Web crawler),是一种按照一定的规则,自动地抓取万维网信息的程序或者脚本. Python的安装 本篇教程采用Python3 来写,所以你需要给你的电脑装上Python ...
- 十、curator recipes之信号量InterProcessSemaphoreV2
简介 跟Java并信号量没有什么不同,curator实现的信号量也是基于令牌桶算法,当一个线程要执行的时候就去桶里面获取令牌,如果有足够的令牌那么我就执行如果没有那么我就阻塞,当线程执行完毕也要将令牌 ...
- c# 使用 Newtonsoft.Json 序列化json字符串以及,反序列化对象
1. 序列化 对象 /** 使用 Newtonsoft.Json 序列化对象 **/ [WebMethod] public String getPersonInfos() { // 初始化数据 Lis ...
- LeetCode GrayCode
class Solution { public: vector<int> grayCode(int n) { vector<int> res; res.push_back(); ...
- 1083 Cantor表
题目描述 Description 现代数学的著名证明之一是Georg Cantor证明了有理数是可枚举的.他是用下面这一张表来证明这一命题的: 1/1 1/2 1/3 1/4 1/5 … 2/1 2/ ...