給nginx配置SSL證書(shū)之后,https可以正常訪(fǎng)問(wèn),http訪(fǎng)問(wèn)顯示400錯(cuò)誤,nginx的配置如下:
server {
listen 80 default backlog=2048;
listen 443;
server_name lvtao.net;
root /var/www/html;
ssl on;
ssl_certificate /usr/local/Tengine/sslcrt/lvtao.net.crt;
ssl_certificate_key /usr/local/Tengine/sslcrt/lvtao.net.key;
}
http訪(fǎng)問(wèn)的時(shí)候钓觉,報(bào)錯(cuò)如下:
400 Bad Request
The plain HTTP requset was sent to HTTPS port. Sorry for the inconvenience.
Please report this message and include the following information to us.
Thank you very much!
說(shuō)是http的請(qǐng)求被發(fā)送到https的端口上去了,所以才會(huì)出現(xiàn)這樣的問(wèn)題坚踩。
server {
listen 80 default backlog=2048;
listen 443 ssl;
server_name lvtao.net;
root /var/www/html;
ssl_certificate /usr/local/Tengine/sslcrt/lvtao.net.crt;
ssl_certificate_key /usr/local/Tengine/sslcrt/lvtao.net.Key;
}
把ssl on荡灾;這行去掉,ssl寫(xiě)在443端口后面瞬铸。這樣http和https的鏈接都可以用批幌,完美解決。