nginx配置文件:html
server { listen 80; listen 443; server_name www.xxx.com; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; ssl on; root html; index index.html index.htm; ssl_certificate /etc/nginx/conf.d/cert/214567143360012.pem; ssl_certificate_key /etc/nginx/conf.d/cert/214567143360012.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; }
訪問https時候正常,不過訪問http的時候會出現
400 Bad Request The plain HTTP request was sent to HTTPS port錯誤nginx
直譯下來就是:普通HTTP請求發送到HTTPS端口。session
參考官方文檔解決方法以下:code
server { listen 80; listen 443 ssl; server_name www.xxx.com; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; root html; index index.html index.htm; ssl_certificate /etc/nginx/conf.d/cert/214567143360012.pem; ssl_certificate_key /etc/nginx/conf.d/cert/214567143360012.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; }
刪掉ssl on; 並在 listen 443; 443後加上ssl便可server