如何在Chrome浏览器中从HSTS列表中永久排除本地主机 [英] How to permanently exclude localhost from HSTS list in Google Chrome

查看:1028
本文介绍了如何在Chrome浏览器中从HSTS列表中永久排除本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 Google Chrome重定向本地主机到https 的后续问题。



有谁知道,如何从Google Chrome的HSTS列表中永久排除 localhost



或者,任何其他优雅的解决方案都不需要开发人员访问 chrome:// net-internals /#hsts 并删除 localhost 每次从HTTPS项目切换到HTTP上的其他项目时都是如此?

解决方案

更新: 您可以为这些域安装适当的SSL证书,如果您想要免费的,所以你不需要混淆HSTS。看一看此处







您可以编辑系统的hosts文件:


  • 在Windows上: C:\Windows\System32\drivers\etc\hosts

  • 在Linux上: / ets / hosts



在那里,您可以为每个项目定义一个不同的域:

  127.0.0.1 project1.local 
127.0.0.1 project2.local
127.0.0.1 projectN.local

保存后,您可以在任何浏览器中导航到这些域,它将从 127.0.0.1 (localhost)加载。如果您使用apache / nginx作为服务器,您可以选择为每个域定义VirtualHosts,这样您不必在每次切换项目时更改您的httpd文件夹。

然后,
$ b

然后当然,您将不得不重新发放任何可能用于新域名项目的证书,但这些证书对于每个项目都是唯一的。在Chrome上,您不需要为不具备证书的项目在每个域中对网络内部进行一次以上的操作(并且对于拥有证书的项目为0次)。


This is a followup question to Google Chrome redirecting localhost to https.

Does anyone know, how to permanently exclude localhost from HSTS list in Google Chrome?

Or, any other elegant solution that wouldn't require developer to visit chrome://net-internals/#hsts and delete localhost every time when switching from working on an HTTPS project to a different project on HTTP?

解决方案

Update:

You can install a proper SSL certificate for those domains if you want to for free, so you won't need to mess around with HSTS. Take a look here.


You may edit your system's hosts file:

  • On Windows: C:\Windows\System32\drivers\etc\hosts
  • On Linux: /ets/hosts

In there you can define a different domain for each project:

 127.0.0.1    project1.local
 127.0.0.1    project2.local
 127.0.0.1    projectN.local

Note: I'm using *.local domains (you can use virtually anything) because you have already set localhost to redirect to https, and such we have to use a different domain. Although I strongly recommend you to install a real SSL certificate and reset to default any modifications you have made on HSTS.

Once saved, when you navigate to those domain in any browser it will load from 127.0.0.1 (localhost). If you use apache/nginx as server you optionally can define VirtualHosts for each domain also so you don't need to change your httpd folder every time you switch projects.

Then of course you will have to re-issue any certificate that you may have for those projects for the new domains, but those would be unique for each project. And on Chrome you would not need to be messing net-internals more than once for each domain for the projects which you don't have a certificate (and 0 times for those with certificate).

这篇关于如何在Chrome浏览器中从HSTS列表中永久排除本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆