問(wèn)題
現(xiàn)在越來(lái)越多的網(wǎng)站要求http
訪問(wèn)轉(zhuǎn)為更為安全的https
訪問(wèn),很多使用nginx部署的前端應(yīng)用可以很方便的使用反向代理來(lái)實(shí)現(xiàn),切換后,用http訪問(wèn)就會(huì)出現(xiàn) "The plain HTTP request was sent to HTTPS port"的錯(cuò)誤頁(yè)面。
解決思路
將此錯(cuò)誤頁(yè)面重定向到指定的https地址即可
解決方法
假設(shè)端口號(hào)是8443:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-515316.html
server {
listen 8443 ssl;
ssl_certificate ssl_cert.pem;
ssl_certificate_key ssl_server.key;
server_name your_domain.com;
error_page 497 https://$host$uri?$args;
location / {
....
}
}
另外,如果是自有域名,http和https端口都使用默認(rèn)端口的話,只要將http的請(qǐng)求重定向到https即可文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-515316.html
server {
listen 80;
listen 443 ssl;
ssl_certificate ssl_cert.pem;
ssl_certificate_key ssl_server.key;
server_name your_domain.com;
if ($scheme = http) {
return 301 https://$host$uri?$args;
}
location / {
....
}
}
到了這里,關(guān)于解決The plain HTTP request was sent to HTTPS port的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!