HTTP and HTTPS simultaneous access methods in Nginx environment

Source: Internet
Author: User

After configuring the SSL certificate for Nginx, HTTPS can be accessed normally, HTTP access shows a 400 error, and 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;}

When HTTP is accessed, the error is as follows:

400 Bad RequestThe 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 HTTP request is sent to the HTTPS port, so this problem occurs.

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

Put SSL on; this line is removed and SSL is written behind port 443. This way HTTP and HTTPS links can be used, the perfect solution.

HTTP and HTTPS simultaneous access methods in Nginx environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.