nginx配置https之使用第三方認證

來源:互聯網
上載者:User

標籤:nginx https

今天中午老大qq上通知我線上伺服器需配置https,然後發來不知從哪兒搞來的認證,讓我整。

我在測試伺服器操作的步驟是如下:

1、檢查nginx的ssl模組--with-http_ssl_module是否安裝,如果沒有需要重新編譯安裝。

[[email protected] ~]# /usr/local/websrv/nginx/sbin/nginx -Vnginx version: nginx/1.6.3built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC) TLS SNI support enabledconfigure arguments: --user=nobody --group=nobody --with-http_ssl_module --with-http_stub_status_module --prefix=/usr/local/websrv/nginx-1.6.3/[[email protected] ~]#

ok!已經安裝完成了,不用重新編譯安裝了。


2、修改nginx設定檔。

在nginx的conf目錄下建立key目錄來存放認證。

[[email protected] ~]# cd /usr/local/websrv/nginx-1.6.3/conf/[[email protected] /usr/local/websrv/nginx-1.6.3/conf]# mkdir key

nginx.conf開啟ssl,在要配置https的網站目錄的server標籤裡添加52-55行

[[email protected] /usr/local/websrv/nginx-1.6.3/conf]# vim nginx.conf.... 48         listen       80; 49         server_name    test.hrfax.cn hrfax.cn; 50 51         #  添加如下   52         listen 443;      53         ssl on; 54         ssl_certificate key/server.crt; 55         ssl_certificate_key key/server.key;            ....


3、上傳認證到/usr/local/websrv/nginx/conf/key目錄下

[[email protected] /usr/local/websrv/nginx-1.6.3/conf]# ls key/server.crt  server.key


4、重新reload nginx讓配置生效。

[[email protected] /usr/local/websrv/nginx-1.6.3/conf]# ../sbin/nginx -tnginx: the configuration file /usr/local/websrv/nginx-1.6.3//conf/nginx.conf syntax is oknginx: configuration file /usr/local/websrv/nginx-1.6.3//conf/nginx.conf test is successful[[email protected]nan1-cloud-test01 /usr/local/websrv/nginx-1.6.3/conf]# ../sbin/nginx -s reload[[email protected] /usr/local/websrv/nginx-1.6.3/conf]# netstat -ntlpua|grep 443       tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      1908/nginx: master


5、用戶端瀏覽器測試。

650) this.width=650;" src="http://s4.51cto.com/wyfs02/M02/89/F2/wKioL1gixz6R-RDuAAMa1IPwyHQ529.jpg-wh_500x0-wm_3-wmp_4-s_865573571.jpg" title="a.jpg" alt="wKioL1gixz6R-RDuAAMa1IPwyHQ529.jpg-wh_50" />

本文出自 “大麥茶” 部落格,請務必保留此出處http://damaicha.blog.51cto.com/6046098/1871086

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.