如何让Chromium系浏览器忽略特定子域名的HSTS强制跳转?
针对Chromium/Chrome/Edge的可行解决方案
1. 自定义启动参数强制跳过HSTS
Chromium系浏览器支持通过启动参数直接指定特定域名绕过HSTS强制跳转,适合给用户配置专用快捷方式:
- 找到Chrome/Edge的快捷方式,右键→属性→目标字段,在原有路径(需保留引号)末尾添加参数:
示例完整目标:--hsts-ignore-list=app.suborg.example.com"C:\Program Files\Google\Chrome\Application\chrome.exe" --hsts-ignore-list=app.suborg.example.com - 启动后访问
http://app.suborg.example.com,浏览器不会强制跳转HTTPS
2. Hosts映射+本地代理(绕开HSTS域名匹配)
利用HSTS基于域名生效的特性,通过本地映射+代理绕开子域限制,同时解决应用硬编码主机名导致的404问题:
- 修改本地
hosts文件:- Windows:
C:\Windows\System32\drivers\etc\hosts - Linux/macOS:
/etc/hosts
添加一行(替换192.168.x.x为应用服务器实际IP):
192.168.x.x app-local - Windows:
- 配置本地代理(以Nginx为例),转发请求并修正响应中的资源路径:
server { listen 80; server_name app-local; location / { proxy_pass http://app.suborg.example.com/; proxy_set_header Host app.suborg.example.com; # 保持原主机名,适配应用硬编码逻辑 sub_filter 'app.suborg.example.com' 'app-local'; # 替换响应中的资源URL,避免404 sub_filter_once off; } } - 用户访问
http://app-local/即可,该域名不在example.com子域,不会触发HSTS强制跳转
3. 浏览器扩展强制降级HTTP请求
使用支持自定义规则的请求拦截扩展,强制指定域名使用HTTP:
- 以「HTTP Everywhere」为例,创建自定义规则文件:
<ruleset name="App Suborg (Force HTTP)"> <target host="app.suborg.example.com"/> <rule from="^https://app.suborg.example.com/" to="http://app.suborg.example.com/"/> </ruleset> - 导入规则后,扩展会自动将该域名的HTTPS请求降级为HTTP
4. 自动化重置HSTS存储脚本
编写脚本一键清除浏览器HSTS存储,比手动操作更高效:
- Windows批处理(需关闭Chrome后运行):
@echo off set CHROME_DATA_DIR=%LOCALAPPDATA%\Google\Chrome\User Data\Default del "%CHROME_DATA_DIR%\TransportSecurity" echo HSTS存储已重置 - Linux/macOS Shell脚本:
rm ~/.config/google-chrome/Default/TransportSecurity echo HSTS storage reset
内容的提问来源于stack exchange,提问作者Cpt.Whale
相关产品推荐
相关产品推荐

