Nginx配置Https

來源:互聯網
上載者:User

標籤:bundle   sha   連接埠配置   listen   src   cat   分享   ges   9.png   

1.申請認證:

https://console.qcloud.com/ssl?utm_source=yingyongbao&utm_medium=ssl&utm_campaign=qcloud

 

2.將認證匯入伺服器,xftp或者FileZilla都可以:

3.修改Nginx,我的Nginx位於/etc/nginx/ :

 

 

Nginx內建ssl配置,刪掉注釋,修改認證位置就好了。

 

80連接埠配置:

server {        listen       80 default_server;        listen       [::]:80 default_server;        server_name  _;        #root         /usr/share/nginx/html;
     #注意添加下面這行代碼,用於重新導向 rewrite ^(.*) https://$server_name$1 permanent; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }

443連接埠設定:

server {        listen       443 ssl http2 default_server;        listen       [::]:443 ssl http2 default_server;        server_name  _;        root         /usr/share/nginx/html;#        ssl_certificate "/etc/pki/nginx/server.crt";#        ssl_certificate_key "/etc/pki/nginx/private/server.key";        ssl_certificate /etc/nginx/conf.d/1_www.bincoding.cn_bundle.crt;        ssl_certificate_key /etc/nginx/conf.d/2_www.bincoding.cn.key;        ssl_session_cache shared:SSL:1m;        ssl_session_timeout  10m;        ssl_ciphers HIGH:!aNULL:!MD5;        ssl_prefer_server_ciphers on;        # Load configuration files for the default server block.        include /etc/nginx/default.d/*.conf;        location / {        }        error_page 404 /404.html;            location = /40x.html {        }        error_page 500 502 503 504 /50x.html;            location = /50x.html {        }    }

 

最後記得重啟Nginx :  service nginx restart

 

參考: 

nginx配置https   https://www.v2ex.com/t/309382

常用伺服器配置    https://mozilla.github.io/server-side-tls/ssl-config-generator/

Nginx配置Https

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.