標籤: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之使用第三方認證