Configuring nginx http and https can simultaneously access methods

After nginx configuration for SSL certificates, https be a normal visit, http access display 400 errors, nginx configuration is as follows:

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 access when given as follows:

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!
 
The reason is http request is sent to the https port up, thus giving rise to such a problem.
The ssl on; this line removed, ssl written after 443 port. This link http and https can be used both, the perfect solution, the modified configuration as follows:

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;
}

 

Guess you like

Origin www.cnblogs.com/yxfcnbg/p/11355461.html