Nginx怎么把http升級到https

httphttps的區別是

有的網站,http打開的時候,頁面提示不安全,比如你點擊下面的網站 【其實是同一個網站】

Nginx怎么把http升級到https

Nginx怎么把http升級到https?

怎樣才能去掉這個不安全的提示呢? 從http升級到https唄

最終效果看一下:

Nginx怎么把http升級到https?

Nginx怎么把http升級到https

如果目前有一個網站,要怎么升級為https呢

域名: 511easy.com

有域名了就可以申請免費的ssl證書,如下截圖,基于各個web服務器的證書,我這邊用的是nginx

Nginx怎么把http升級到https

那然后就需要配置nginx.conf的配置了,大概就是用下面的第三個,前兩個是我用來保存的。

?https和http相比,更加安全,不盡然,用jmeter/charles/wireshark/fiddle等,生成一個證書,對https的網站都能進行輕易的抓包,大多數的網站和app,我都能夠進行抓包

?upstream?tomcatserver1?{ ??server?127.0.0.1:8083; ??} ?upstream?tomcatserver2?{ ??server?127.0.0.1:8085; ??} ??? ??? ??? server?{ ??listen??80; ??server_name?511easy.com; ? ? ??location?/?{ ???proxy_pass?http://tomcatserver1; ???index?index.html?index.htm; ??}? ?} server?{ ??listen??80; ??server_name?511easy.com; ? ??location?/?{ ???proxy_pass?http://tomcatserver2; ???index?index.html?index.htm; ??}?? ?}
worker_processes?1; ? events?{ ?worker_connections?1024; } ? ? http?{ ?include??mime.types; ?default_type?application/octet-stream; ? ?sendfile??on; ? ?keepalive_timeout?65; ? ?server?{ ??listen??80; ??server_name?88bugs; ??location?/?{ ???proxy_pass?http://localhost:8083; ??} ??} ? ?server?{ ??listen??80; ??server_name?jenkins; ??location?/?{ ???proxy_pass?http://localhost:8080; ??} ??} }
worker_processes?1; ? events?{ ?worker_connections?1024; } ? ? http?{ ?include??mime.types; ?default_type?application/octet-stream; ? ?sendfile??on; ? ?keepalive_timeout?65; ? ? ??server?{ ??listen?443?ssl; ??server_name?www.511easy.com; ?? ??ssl?????on; ??ssl_certificate??1_511easy.com_bundle.crt; ??ssl_certificate_key???2_511easy.com.key; ??ssl_session_timeout?5m; ??? ??location?/?{ ???proxy_pass?http://localhost:8083; ??} ? ??} }

鞏固一下這幾個縮寫名詞的含義

http — hyper text transfer protocol,超文本傳輸協議,是一種建立在tcp上的無狀態連接,整個基本的工作流程是客戶端發送一個http請求

https —- hyper text transfer protocol over secure socket layer 或 hypertext transfer protocol secure

全稱是:超文本安全傳輸協議,可以簡單理解為使用ssl加密傳輸的http協議

http的默認端口是80,https的默認端口是443
ssl是為網絡通信提供安全及數據完整性的一種安全協議。

為什么要使用https

為了保護信息傳輸的安全性,數據完整性。讓訪客覺得網站可信任,對于國內的網絡環境,也可以防止寬帶運營商強制給網站掛廣告。

如果希望一臺服務器上,兩個端口,分別用不用的域名執行不同的端口,nginx可以這么配置

worker_processes?1; ? events?{ ?worker_connections?1024; } ? ? http?{ ?include??mime.types; ?default_type?application/octet-stream; ? ?sendfile??on; ? ?keepalive_timeout?65; ? ? ??server?{ ??listen?443?ssl; ??server_name?www.88bugs.com; ?? ??ssl_certificate??1_88bugs.com_bundle.crt; ??ssl_certificate_key?2_88bugs.com.key; ??ssl_session_timeout?5m; ??? ??location?/?{ ???proxy_pass?http://localhost:8083; ??} ??} ?? ??server?{ ??listen?443?ssl; ??server_name?www.511easy.com; ?? ??ssl_certificate??1_511easy.com_bundle.crt; ??ssl_certificate_key?2_511easy.com.key; ??ssl_session_timeout?5m; ??? ??location?/?{ ???proxy_pass?http://localhost:8085; ??} ??}? }

? 版權聲明
THE END
喜歡就支持一下吧
點贊11 分享