歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> Nginx配置同一個域名同時支持http與https兩種方式訪問,nginxhttps

Nginx配置同一個域名同時支持http與https兩種方式訪問,nginxhttps

日期:2017/3/3 17:25:19   编辑:學習Linux

Nginx配置同一個域名同時支持http與https兩種方式訪問,nginxhttps


熱度1 評論 159 www.BkJia.Com 網友分享於: 2017-02-25 04:02:44 浏覽數23048次

Nginx配置同一個域名同時支持http與https兩種方式訪問,nginxhttps


Nginx配置同一個域名http與https兩種方式都可訪問,證書是阿裡雲上免費申請的

server
{
listen 80;
listen 443 ssl;
ssl on;
server_name 域名;
index index.html index.htm index.php default.html default.htm default.php;
ssl_certificate /usr/local/nginx/cert/21402058063066221.pem; //下載申請後阿裡ssh提供的pem
ssl_certificate_key /usr/local/nginx/cert/21402058063066221.key;//下載申請後阿裡ssh提供的key
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;

root /home/wwwroot/網站目錄;

include laravel.conf; //好吧,這裡是laravel配置,不一定合適您哈,請或略
#error_page 404 /404.html;
include enable-php.conf;

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

access_log /home/wwwlogs/airclass.mime.org.cn.log;
}

關鍵在於上面的listen 80;
listen 443 ssl; 開啟80端口

http://www.bkjia.com/Linuxjc/1195495.htmlwww.bkjia.comtrue

Copyright © Linux教程網 All Rights Reserved