IIS 配置 HTTP 自动跳转到 HTTPS

To enable HTTP Strict Transport Security (HSTS) in IIS, need to add the appropriate headers to your web server's configuration:

  1. Open IIS Manager: Start by opening the Internet Information Services (IIS) Manager.
  2. Select Your Site: In the Connections pane, expand the node for your server, and then expand the Sites node. Select the site you want to configure.
  3. Open HTTP Response Headers: In the Features View, double-click on the "HTTP Response Headers" feature.
  4. Add HSTS Header: In the Actions pane on the right, click on "Add..." to add a new HTTP response header. Use the following settings:
  • Name: Strict-Transport-Security
  • Value: max-age=31536000; includeSubDomains
    
    This configuration sets the HSTS policy to a max age of one year and includes all subdomains.
    Here's a sample configuration code for adding the HSTS header using the web.config file:
<configuration>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

This code should be placed within the <configuration> section of your web.config file.

5. Restart IIS

posted @   Robot-Blog  阅读(81)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示