AI正在生成摘要
宝塔面板启用 SSL 后,默认站点未指定时,HTTPS 会访问已开启 SSL 的站点,即“https窜站”。解决方法是在宝塔面板中添加一个站点域名并配置 SSL 证书,将默认站点设置为该域名。如果需要,可删除该域名的 404.html 和 index.html 文件。
群里有人问,为什么用宝塔面板网站搭建好后 https://ip 也能打开他的网站?
按照宝塔官方说法:在未指定默认站点时,未开启 SSL 的站点使用 HTTPS 会直接访问到已开启 SSL 的站点。
这也就是大家常说的的https窜站!
新版宝塔已经没有这个问题了,网站列表管理中直接打开 HTTPS 防窜站就好。
但是有很多人还是用旧版宝塔的,毕竟新版的宝塔一言难尽,于是就水一篇吧~~
这问题具体有什么影响就不多说了,直接说解决方案。
宝塔面板中添加站点
域名为a.com(可以随便填),提交。
给 a.com 配置 SSL 证书
密钥和证书填写如下
密钥(KEY)
-----BEGIN PRIVATE KEY----- MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDPPPynNLmSGfC8 CXODplocOVy/Re9lEhpGtxm0hBoEh3dO61yr2oo8K7Z761o6pkP4Wll+8PaWGGgY IYORsI1DxgTJ0hCdeLy+tJbTZYmbcpboqGD62T68pf4Opsb6ntwWScjFiN1nrqW5 9ctyiOlQmeX48mEv7VxTdHPCdhTwVsbEeFlMbTQfrh88Ph/TmgIJ5gbwRblBEv2T 6oqNQP3u5IFeMI3ACs7ryxSQixfkpktVo72XO8VemgreCvjH8co4fd0788HcYbdV 031o5gqSvmBM1Pz+Lkb+XRP0rpLul/ArEUQ9MAySIr7GskULZD9sue0YQfAHeNrZ 43Zdbe9xAgMBAAECggEBAK3n680UvbUQ96eT9s+/RVbx/Ba2xVH3gv1cocGOKZcr Zr9fWwEL/3zG4ffTZIBbDibXCssvwn3qNVAqr5IOqjz5awNBuJesvhb6zKbRSkyc OG88/UUEEVWVpkD9S3T84owBlu3NEJ71PDV1Qij3I3Nz8jyaiVwCv7t4ubuyA5g6 dy+Y6PnDQ9do8spQDJLQbisAGiyUSuV7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KUiWMQH12iQgN2jCoOxR -----END CERTIFICATE-----
设置默认站点为 a.com
如有必要,可以去a.com文件夹内删掉404.html和index.html。
搞定!
其实说白了就是新建一个虚假域名的默认站点,添加一个自签的证书。
有需要的可以参考。