最新文章转自个人博客地址:https://www.no-if.com/
html设置 (页面数据请求地址)
站内加载的资源自动将http转为https
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
apache配置 (页面访问地址)
#修改或在根目录下添加.htaccess文件
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{
SERVER_PORT} !^443$
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R=301,L]
</IfModule>
Tomcat 配置
打开 Tomcat 配置文件 conf\server.xml。
取消注释,并添加两个属性 keystoreFile,keystorePass
//1、8080端口改为80
//2、8443端口该改为如下:主要添加keystoreFile、keystorePass两个证书属性
<Connector URIEncoding="UTF-8" SSLEnabled="true" clientAuth="false"
keystoreFile="conf/tomcat.keystore" keystorePass="123456"
maxThreads="150" port="8443"
protocol="org.apache.coyote.http11.Http11NioProtocol"
scheme="https" secure="true" sslProtocol="TLS"/>
//3、注释conf\server.xml文件中下面一行
<!--<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />-->
//4、在web.xml末尾加上如下配置:
<security-constraint>
<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>
IIS配置
需要在网站根目录下的web.config文件中(没有需要创建,需要支持.NET),然后在该文件里面添加下面代码:
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<math url="(.*)"/>
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true"/>
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}">
</rule>
阿里云CDN设置
1、点击CDN 进入域名管理
2、添加你的域名
3、在新添加得域名后面点击管理
4、进入https设置
5、点击强制跳转
6、点击修改配置 http->https
7、完成