设置tomcat访问http时自动跳转到https

tomcat8
conf/server.xml
中原属于80端口的http修改为(tomcat默认是8080端口)

<Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="443" />
之后在conf/web.xml的最下面</web-app>前加上

<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://www.cnblogs.com/qianzf/p/12158392.html

时间: 2024-08-27 21:23:23

设置tomcat访问http时自动跳转到https的相关文章

apache如何设置http自动跳转到https

https://www.cnblogs.com/niejunlei/p/5279677.html 如何设置http自动跳转到https? apache环境下,配置好https后,需要设置url重定向规则,使网站页面的http访问都自动转到https访问. 1.先打开url重定向支持 1)打开Apache/conf/httpd.conf,找到 #LoadModule rewrite_module modules/mod_rewrite.so 去掉#号. 2)找到你网站目录的<Directory>

设置tomcat访问根路径

不设置访问根路径的话,必须在访问路径前加上webapp中的项目文件夹名字才能访问,这样就会造成一些问题,比如SpringMVC在写RequestMapping时映射路径配置的@RequestMapping("/hello"),这个接口发布到tomcat上时按照预期的路径访问不到,就会出现404. 设置tomcat访问根路径的方法: 在tomcat安装目录/conf/下得server.xml中,在<Host>节点配置子节点 <Context path="&qu

nginx配置http访问自动跳转到https

一.按照如下格式修改nginx.conf 配置文件,80端口会自动转给443端口,这样就强制使用SSL证书加密了.访问http的时候会自动跳转到https上面. server { listen 80; server_name www.域名.com; rewrite ^(.*) https://$server_name$1 permanent; } server { listen 443; server_name www.域名.com; root /home/www; ssl on; ssl_ce

Apache由http自动跳转到https的方法

修改根目录.htaccess文件 <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On #thinkphp去掉index.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] #http自动跳转到https RewriteCond %{

IIS (安装SSL证书后) 实现 HTTP 自动跳转到 HTTPS

IIS 里 安装好 SSL 证书后,如何实现 在浏览器里录入 http://www.xxx.com,会自动跳转到 https://www.xxx.com 呢. 首先,下载并安装 IIS 扩展: URL重写(URL Rewrite)扩展 URL重写扩展下载地址: https://www.iis.net/downloads/microsoft/url-rewrite 其次,修改 web.config 文件: <?xml version="1.0" encoding="UTF

IIS7 http自动跳转到https

IIS7 http自动跳转到https(通过编辑Web.config实现) 原文地址:https://www.cnblogs.com/coce/p/11247404.html

Tomcat配置https及访问http自动跳转至https

https介绍:   HTTPS(全称:Hypertext Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版.即HTTP下加入SSL层,HTTPS的安全基础是SSL,因此加密的详细内容就需要SSL. 它是一个URI scheme(抽象标识符体系),句法类同http:体系.用于安全的HTTP数据传输.https:URL表明它使用了HTTPS,但HTTPS存在不同于HTTP的默认端口及一个加密/身份验证层(

google.com 不能访问,会自动跳到google.ca

使用Google浏览器的时候.这里我直接在输入框上search的时候不能使用.他们跳转到google.ca上,且无法解析.这里的解决方法是 在使用Chrome的时候,Google为增强本地化搜索,或将默认的Google搜索引擎转换为本地语言,如在中国会自动转到google.com.hk,日本会会自动转到google.co.jp,如果你是一个Google.com控,比如博主我就是,不喜欢这种方式的话,你可以自己动手将其改为Google.com而不进行自动跳转. 通常情况下,Google Chrom

手机访问PC网站自动跳转到手机网站代码(转)

4G时代,手机网站已经非常普遍了,一般手机网站都有一个二级域名来访问,比如 m.16css.com 如果手机直接访问www.16css.com 就是PC网站,在手机上浏览电脑版网站体验非常不好. 如果能够手机访问PC端电脑网站自动跳转到手机网站就好了: 代码如下: 将以下代码放在首页区 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 3