nginx / 引发的400 The plain HTTP request was sent to HTTPS port
问题:
使用nginx反向代理并将所有80转到443,访问 https://域名/login 出现问题如下,访问 https://域名/login/ 正常显示,但是点击登录无法发送请求仅仅刷新验证码。求解答
<html> <head> <title> 400 The plain HTTP request was sent to HTTPS port </title> </head> <body> <center> <h1> 400 Bad Request </h1> </center> <center> The plain HTTP request was sent to HTTPS port </center> <hr> <center> nginx </center> </body> </html>
nginx配置:
server { listen 80; server_name ***.com; rewrite ^(.*)$ https://$host$1; location /.well-known/pki-validation { root /home/user/soft/nginx/html; } } server { #HTTPS的默认访问端口443。 #如果未在此处配置HTTPS的默认访问端口,可能会造成Nginx无法启动。 listen 443 ssl; #填写证书绑定的域名 server_name xxxx; #填写证书文件名称 ssl_certificate /home/user/soft/nginx/html/*.pem; #填写证书私钥文件名称 ssl_certificate_key /home/user/soft/nginx/html/*.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; #自定义设置使用的TLS协议的类型以及加密套件(以下为配置示例,请您自行评估是否需要配置) #TLS协议版本越高,HTTPS通信的安全性越高,但是相较于低版本TLS协议,高版本TLS协议对浏览器的兼容性较差。 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; #表示优先使用服务端加密套件。默认开启 ssl_prefer_server_ciphers on; include /*.conf; location / { root html; index index.html index.htm; }