探索,發現,愛好、學習,記錄,分享。
學海無涯,天涯若比鄰,三人行,必有我師。

nginx https配置方法:http和https共存

nginx怎么配置https,nginx配置https方法,nginx中如何实现https和http都可访问。

给nginx配置SSL证书之后,https可以正常访问,http访问显示400错误,nginx的配置如下:

server {

listen 80 default backlog=2048;

listen 443;

server_name wosign.com;

root /var/www/html;

ssl on;

ssl_certificate /usr/local/Tengine/sslcrt/ wosign.com.crt;

ssl_certificate_key /usr/local/Tengine/sslcrt/ wosign.com .key;

}

http访问的时候,报错如下:

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!

 

说是http的请求被发送到https的端口上去了,所以才会出现这样的问题。

server {

listen 80 default backlog=2048;

listen 443 ssl;

server_name wosign.com;

root /var/www/html;

 

ssl_certificate /usr/local/Tengine/sslcrt/ wosign.com.crt;

ssl_certificate_key /usr/local/Tengine/sslcrt/ wosign.com .Key;

}

把ssl on;这行去掉,ssl写在443端口后面。这样http和https的链接都可以用,完美解决。

版權聲明:本文采用知識共享 署名4.0國際許可協議 [BY-NC-SA] 進行授權
轉載事宜:如需轉載需徵得應允,轉載必須注明來源於本站的信息。
文章名称:《nginx https配置方法:http和https共存》
文章链接:https://www.thefreesky.com/blog/23465.html
本站資源僅供個人學習交流,請於下載後24小時內刪除,不允許用於商業用途,否則法律問題自行承擔。

評論 抢沙发