nginx 报错 The plain HTTP request was sent to HTTPS port

https://hostname:4441

nginx监听4441端口使用https协议,浏览器输入http://hostname:4441报错

The plain HTTP request was sent to HTTPS port

原因是如果用户在使用 http 访问时,就会报497错误,

用error_page 处理一下即可:

server {
    listen       4441 ssl;
    ...
    ...
    error_page  497 https://$host:4441;
}

 

posted @ 2021-01-08 17:44  _DC  阅读(4651)  评论(0编辑  收藏  举报