最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Linux下nginx配置https協(xié)議訪問的方法

 更新時間:2016年07月26日 14:24:30   投稿:mdxy-dxy  
這篇文章主要介紹了Linux下nginx配置https協(xié)議訪問的方法,需要的朋友可以參考下

一、配置nginx支持https協(xié)議訪問,需要在編譯安裝nginx的時候添加相應的模塊--with-http_ssl_module

查看nginx編譯參數(shù):/usr/local/nginx/sbin/nginx -V

如下所示:

configure arguments: --prefix=/usr/local/nginx --with-google_perftools_module --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35

如果沒有--with-http_gzip_static_module這個參數(shù),需要重新編輯nginx

二、防火墻開啟https協(xié)議默認端口443

vi /etc/sysconfig/iptables #編輯防火墻配置文件,添加以下代碼

-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

:wq! #保存退出

service iptables restart #重啟防火墻

三、創(chuàng)建https證書

確保機器上安裝了openssl和openssl-devel

yum install openssl openssl-devel #CentOS使用yum命令安裝

mkdir /usr/local/nginx/conf/ssl #創(chuàng)建證書存放目錄

cd /usr/local/nginx/conf/ssl #進入目錄

創(chuàng)建服務器私鑰:openssl genrsa -des3 -out server.key 1024 #根據(jù)提示輸入證書口令

創(chuàng)建簽名請求的證書(CSR):openssl req -new -key server.key -out server.csr #輸入上面設置的口令

#根據(jù)提示輸入相應的信息

Country Name (2 letter code) [XX]:cn #國家

State or Province Name (full name) []:zhejiang #省份

Locality Name (eg, city) [Default City]:hangzhou #城市

Organization Name (eg, company) [Default Company Ltd]:osyunwei #公司

Organizational Unit Name (eg, section) []:sys #部門

Common Name (eg, your name or your server's hostname) []:osyunwei #主機名稱

Email Address []:[email protected] #郵箱

Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []:123456 #證書請求密鑰,CA讀取證書的時候需要輸入密碼

An optional company name []:osyunwei #公司名稱,CA讀取證書的時候需要輸入密碼

openssl rsa -in server.key -out server_nopassword.key #對key進行解密

openssl x509 -req -days 365 -in server.csr -signkey server_nopassword.key -out server.crt

#標記證書使用上述私鑰和CSR

四、修改nginx配置文件,加載ssl證書

vi /usr/local/nginx/conf/nginx.conf #編輯

listen 80;

listen 443;

ssl on;

ssl_certificate /usr/local/nginx/conf/ssl/server.crt;

ssl_certificate_key /usr/local/nginx/conf/ssl/server_nopassword.key;

fastcgi_param HTTPS $https if_not_empty; #有https協(xié)議時自動使用https,否則忽略這個參數(shù)。

:wq! #保存退出

service nginx restart #重啟nginx

rewrite ^(.*) https://www.osyunwei.com$1 permanent; #可以把http協(xié)議重定向到https上面

使用https協(xié)議打開網(wǎng)址,如下圖所示:

至此,Linux下nginx配置https協(xié)議訪問完成。

相關(guān)文章

最新評論

保山市| 香格里拉县| 兰西县| 游戏| 思茅市| 石渠县| 绥阳县| 平安县| 兴义市| 沅陵县| 辛集市| 汤原县| 德格县| 石河子市| 固始县| 永昌县| 灵璧县| 西林县| 紫阳县| 巴林右旗| 天长市| 宿松县| 泸西县| 梅河口市| 梁山县| 怀集县| 建阳市| 乐平市| 台东县| 临夏市| 罗甸县| 儋州市| 开鲁县| 普安县| 顺义区| 定结县| 关岭| 泾阳县| 禹州市| 客服| 宁陵县|