Windows IIS 10如何配置自签名SSL并实现自动跳转
2023-06-13 09:17:43 时间
配置自签名难度不大,但是有一些坑路,所以在这里记录一下。
1. 配置自签名的坑路
配置自签名,这里就不进行详细说明了。网上有大量的链接:
在配置好443端口的时候,服务器可能会无法再次启动,原因搜索了一下,说是443端口被占用。其实解决方法是直接重启即可。
2. HTTP跳转HTTPS
使用中文搜索,得到的是很多年前的教程,实际上都不适用于IIS 10。 正确的做法是下载插件。
2.1 下载并安装URL Rewrite插件
下载地址: https://www.iis.net/downloads/microsoft/url-rewrite 等待下载并安装好之后,需要退出一下IIS。因为这个时候IIS Manager里面URL Rewrite还没显示出来。 我们需要设置Web Config去修改。
2.2 设置Web Config
在你网站的根目录,有一个web.config的文件,把代码嵌入:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to HTTPS" enabled="false" stopProcessing="true">
<match url="(.*)" />
<conditions><add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
由于我本来里面已经有配置,所以修改了一下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".pkg" mimeType="application/macos" />
<mimeMap fileExtension=".ipa" mimeType="application/ipad" />
</staticContent>
<directoryBrowse enabled="true" />
<rewrite>
<rules>
<rule name="Redirect to HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
如你所见,我之前通过MIME Types添加了pkg和ipa文件,这样用户访问就会直接下载,而不会是报错。 现在我又添加了HTTPS自动跳转。
2.3 IIS Manager查看效果
现在,你只需要进入URL Rewrite并点击“Redirect to HTTPS”然后Enable Rule即可。
2.4 注意IIS早期版本教程导致坑路
记得在SSL Setting里面,不要勾选Require SSL! 否则会返回403.4错误。
相关文章
- 未能连接一个windows服务器,Win7出现未能连接一个Windows服务的解决办法
- windows下安装MinGW及C++的环境配置
- Windows命令窗口输入命令报错不是内部或外部命令,也不是可运行的程序 或批处理文件
- 经验分享 | HVV之windows应急笔记
- windows安装git cmd_git for windows
- Windows编译ollvm_windows交叉编译linux
- Adobe Media Encoder 2023 for Windows 直装版
- Codeql在windows上配置及使用
- 「 使用docker for windows关于迁移目录的教程 」
- Windows中IIS内FTP服务器高级配置教程
- ORA-09365: Windows 3.1 Two-Task driver unable to destroy hidden window ORACLE 报错 故障修复 远程处理
- Node.js安装及环境配置之Windows篇详解编程语言
- /windows轻松安装双系统:Linux 与 Windows 互补配置(如何安装双系统linux)
- windows比较:Linux和Windows的优势与劣势(linuxvss)
- Windows 11功能更新微软透露每年只会发布一次升级
- 微软发布新版兼容性检查工具 可以说明PC为何不支持升级Windows 11
- 树莓派基于 Raspbian 的 Windows XP 现已可用
- Windows 10各版本占比:20H2成最稳定选择 近4成用户选择
- 微软:Win11 十分受用户欢迎,预览版下载量超过其他任何 Windows,正式版将在秋季发布
- 数据库安装MySQL数据库驱动程序:Windows 7上的指南(win7用的mysql)
- 和 windows比较: Getty Linux 与 Windows(gettylinux)
- 0day! 0day!Windows 7 和 Windows Office 均被曝 0day
- Oracle安全加固之SSL配置(oracle配置ssl)
- 在Windows上运行WSL Linux:开启新的技术革新之路.(wsllinux)
- 让Windows启动Redis服务,实现更稳定的体验(在win启动redis)
- Windows下XDebug手工配置与使用说明
- Windows下RubyonRails开发环境安装配置图文教程