问题描述
The plain HTTP request was sent to HTTPS port
当访问用http时则报错。用https时不报错。
检查配置:
server {
listen 80 ssl;
server_name hngj.zxynyxxx.cn;
ssl_certificate /usr/local/nginx/cert/hngj.zxynyxxx.cn.pem;
ssl_certificate_key /usr/local/nginx/cert/hngj.zxynyxxx.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
try_files $uri /index.html;
charset utf-8;
gzip on;
其他配置略
}
解决办法
修改“listen 80 ssl;”为“listen 80 ;”
增加 “listen 443 ssl;”
这样Nginx就可以同时处理HTTP请求和HTTPS请求了。
配置参考如图:
server {
listen 80 ;
listen 443 ssl;
server_name hngj.zxynyxxx.cn;
ssl_certificate /usr/local/nginx/cert/hngj.zxynyxxx.cn.pem;
ssl_certificate_key /usr/local/nginx/cert/hngj.zxynyxxx.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
try_files $uri /index.html;
charset utf-8;
gzip on;
其他配置略
}
标签:hngj,HTTP,cn,nginx,plain,request,server,ssl,listen
From: https://www.cnblogs.com/zoujiaojiao/p/17728106.html