tomcat设置http自动跳转为https访问
本实验环境:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[root@localhost conf] # cd /usr/local/tomcat/bin/
[root@localhost bin] # ./version.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1 .7.0_75
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap .jar
Server version: Apache Tomcat /6 .0.41
Server built: May 19 2014 11:49:25
Server number: 6.0.41.0
OS Name: Linux
OS Version: 2.6.32-431.el6.i686
Architecture: i386
JVM Version: 1.7.0_75-b13
JVM Vendor: Oracle Corporation
[root@localhost bin] #
|
基于jdk的keytool工具生成key,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
[root@localhost ~] # find / -name keytool
/usr/java/jdk1 .7.0_75 /jre/bin/keytool
/usr/java/jdk1 .7.0_75 /bin/keytool
[root@localhost ~] # cd /usr/java/jdk1.7.0_75/bin/
#/usr/local/tomcat/tomcat.keystore 证书存放位置; -validity 36500证书有效期,36500表示100年,默认值是90天
[root@localhost bin] # ./keytool -genkey -alias tomcat -keyalg RSA -keystore /usr/local/tomcat/tomcat.keystore -validity 36500
Enter keystore password: #此处需要输入大于6个字符的字符串
Re-enter new password:
What is your first and last name? #“您的名字与姓氏是什么?”这是必填项,并且必须是TOMCAT部署主机的域名或者IP[如:pvbutler.blog.51cto.com 或者 10.15.24.254],就是你将来要在浏览器中输入的访问地址
[Unknown]: 10.15.24.254
What is the name of your organizational unit? #“你的组织单位名称是什么?”可以按照需要填写也可以不填写直接回车,实验中直接回车
[Unknown]:
What is the name of your organization? #“您的组织名称是什么?”,同上直接回车
[Unknown]:
What is the name of your City or Locality? #“您所在城市或区域名称是什么?,同上直接回车
[Unknown]:
What is the name of your State or Province? #“您所在的州或者省份名称是什么?”
[Unknown]:
What is the two-letter country code for this unit? #“该单位的两字母国家代码是什么?”
[Unknown]:
Is CN=10.15.24.254, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct? #系统询问“正确吗?”时,对照输入信息,如果符合要求则使用键盘输入字母“y”,否则输入“n”重新填写上面的信息
[no]: y
Enter key password for <tomcat>
(RETURN if same as keystore password): #输入<tomcat>的主密码,这项较为重要,会在tomcat配置文件中使用,建议输入与keystore的密码一致,设置其它密码也可以
Re-enter new password:
[root@localhost bin] # #此时会在/usr/local/tomcat中生成文件tomcat.keystore
|
修改配置tomcat服务器
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
[root@localhost bin] # cd /usr/local/tomcat/conf/
[root@localhost conf] # cp server.xml server.xmlbak
[root@localhost conf] # cp web.xml web.xmlbak
[root@localhost conf] # vim server.xml
69 <Connector port= "80" protocol= "HTTP/1.1"
70 connectionTimeout= "20000"
71 redirectPort= "443" /> #将redirectPort="8443"修改为redirectPort="443"
83 #去掉注释<!--和-->;修改port="8443"为port="443";指定证书文件的位置和<tomcat>的主密码keystoreFile="/usr/local/tomcat/tomcat.keystore" key storePass="justin"
84 <Connector port= "443" protocol= "HTTP/1.1" SSLEnabled= "true"
85 maxThreads= "150" scheme= "https" secure= "true" 86 clientAuth= "false" sslProtocol= "TLS" keystoreFile= "/usr/local/tomcat/tomcat.keystore" key storePass= "justin" />
87
#将redirectPort="8443"修改为redirectPort="443"
90 <Connector port= "8009" enableLookups= "false" protocol= "AJP/1.3" redirectPort= "443" />
[root@localhost conf] #
[root@localhost conf] # vim web.xml
4634
4635 <welcome- file -list>
4636 <welcome- file >index.html< /welcome-file >
4637 <welcome- file >index.htm< /welcome-file >
4638 <welcome- file >index.jsp< /welcome-file >
4639 < /welcome-file-list >
#在文件</welcome-file-list>后面加上以下语句:
4640 <login-config>
4641 <!-- Authorization setting for SSL -->
4642 <auth-method>CLIENT-CERT< /auth-method >
4643 <realm-name>Client Cert Users-only Area< /realm-name >
4644 < /login-config >
4645 <security-constraint>
4646 <!-- Authorization setting for SSL -->
4647 <web-resource-collection >
4648 <web-resource-name >SSL< /web-resource-name >
4649 <url-pattern>/*< /url-pattern >
4650 < /web-resource-collection >
4651 <user-data-constraint>
4652 <transport-guarantee>CONFIDENTIAL< /transport-guarantee >
4653 < /user-data-constraint >
4654 < /security-constraint >
[root@localhost conf] # service tomcat stop
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1 .7.0_75
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap .jar
[root@localhost conf] # service tomcat start
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1 .7.0_75
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap .jar
[root@localhost conf] #
|
上述配置完成后,重启TOMCAT后即可以使用SSL。IE地址栏中可以直接输入地址 “http://” 会自动跳转成为 “https://” ,windows环境类似,可参考修改对应文件。
注意事项:
(1)生成证书的时间,如果IE客户端所在机器的时间早于证书生效时间,或者晚于有效时间,IE会提示“该安全证书已到期或还未生效”
(2)如果IE提示“安全证书上的名称无效或者与站点名称不匹配”,则是由生成证书时填写的服务器所在主机的域名“您的名字与姓氏是什么?”/“What is your first and last name?”不正确引起的
(3)如果AC主机不能通过域名查找,必须使用IP,但是这个IP只有在配置后才能确定,这样证书就必须在AC确定IP地址后才能生成
(4)证书文件只能绑定一个IP地址,假设有10.1.25.250 和 192.168.1.250 两个IP地址,在证书生成文件时,如使用了10.1.25.250,通过IE就只能使用10.1.25.250 来访问AC-WEB,192.168.1.250是无法访问AC-WEB的
本文转自 justin_peng 51CTO博客,原文链接:http://blog.51cto.com/ityunwei2017/1650958,如需转载请自行联系原作者
tomcat设置http自动跳转为https访问相关推荐
- Tomcat设置Http自动跳转Https
Https相关介绍 Https是由NetScape公司设计的一个基于Http的加密传输协议,可以这样理解Https = Http +SSL(安全套接层),Https的默认端口为443,而且还需要申请C ...
- 阿里云服务器给WordPress网站添加SSL证书,并且设置http自动跳转https
给WordPress网站添加SSL证书,并且设置http自动跳转https 文章目录 下载证书到本地 上传证书到服务器 修改nginx配置文件 设置http跳转https 重启Nginx服务 联系方式 ...
- 设置http自动跳转https
nginx设置http自动跳转到https,配置文件如下: server {listen 80 ;listen 443 ssl http2 ;server_name xxx.xxx.com;serve ...
- IIS设置http自动跳转https
两种方法 第一种 IIs中实现Http自动转换到Https方法介绍 (403跳转对SEO有一定影响) 1.根据IIS版本备份以下文件: IIS6.0 路径:C:\WINDOWS\Help\iisHel ...
- chrome设置http自动跳转https
输入网址:chrome://net-internals/#hsts,在下图的domain中输入需要修改的域名,如:aa.com,回车即可.
- HTTP Strict Transport Security 导致的307 http自动跳转https
今天遇到一个 由于nginx设置了header:Strict-Transport-Security导致url自动跳转为https的问题. 记录如下: 开发者模式下可以看到307及hsts类提示信息 可 ...
- 配置跳转指定_http自动跳转https的配置方法
这篇文章主要介绍了http自动跳转https的配置方法,需要的朋友可以参考下 IIs中实现Http自动转换到Https方法介绍 (403跳转对SEO有一定影响) 1.下载安装URL重写模块:Micro ...
- 开启HSTS让浏览器强制跳转HTTPS访问
开启HSTS让浏览器强制跳转HTTPS访问 来源 https://www.cnblogs.com/luckcs/articles/6944535.html 在网站全站HTTPS后,如果用户手动敲入网站 ...
- 网站服务器如何配置跳转,http自动跳转https的配置方法
IIs中实现Http自动转换到Https方法介绍 (403跳转对SEO有一定影响) 1.下载安装URL重写模块:Microsoft URL Rewrite Module 32位:http://down ...
最新文章
- 基于YOLOv5模型压缩、模型量化、模型剪枝
- Django的第二次尝试
- HashFlare矿池退出BTC挖矿,Coingeek矿池继续增加BCH算力
- 行为模式之Visitor模式
- golang中的空slice
- 岗位内推 | 微软亚洲互联网工程院自然语言处理组招聘
- c语言构建栈_选择技术栈构建通用平台
- 使用SwingWorker的Java Swing中的多线程
- Kubernetes 并非灵丹妙药...
- 【bzoj5110】[CodePlus2017]Yazid 的新生舞会 Treap
- 启动服务提示-bash: mongod: command not found
- 读书笔记(chapter18)
- zTree模糊搜索(子级和父级都不匹配时隐藏节点)
- HorizontalListView中setSelection方法没有实现的数据刷新的解决方法
- Git工程区域与文件状态
- 收藏behavior designer中文教程
- cp: omitting directory `XXX'问题解决
- PHP 7.0+新特性
- 白盒测试与黑盒测试--(详解)
- GPL amp; LGPL
热门文章
- 跨浏览器用javascript获取窗口的位置和大小
- Ubuntu安装aira2及开机启动配置
- Dex文件格式扫描器:特征API的检测和扫描-小工具一枚(转载)
- 北林oj-算法设计与分析-Simple Count(C++,思路+代码)
- oracle 视图及函数授权,Oracle常见1000问之内部函数及管理视图
- 模拟ios_王者荣耀策划Donny:安卓IOS今年或实现互通!模拟战一周一更新
- python小测试1答案_测试1:Python 基本语法(选择题
- 6s电路图纸 iphone_(分享)iphone6s原理图、点位图(维修必备)
- Detect to Track and Track to Detect
- Wait Event Disk file operations I/O