Nginx 配置https 开启ssl 同时支持http

 1 server {
 2         listen              80;
 3         listen              443 ssl;
 4         server_name         default;
 5 
 6         index               index.html index.php;
 7         root /www/html;
 8         access_log          /var/log/nginx/pay.access.log main buffer=32k;
 9         rewrite_log on;
10 
11         more_set_headers    'Server: $server_name';
12         more_set_headers    -s '400 403 404 405 413 414 500 502 503 504'  'Server: $hostname';
13 
14 
15         # 此处为ssl 配置
16         ssl_certificate     /usr/local/nginx/cert/test.com.crt;    # *.crt文件路径
17         ssl_certificate_key /usr/local/nginx/cert/test.com.key; # *.key文件路径
18         ssl_session_cache   shared:SSL:128m;
19         ssl_session_timeout 10m;
20 
21         location ~ \.php$ {
22                 fastcgi_pass    127.0.0.1:9000;
23                 fastcgi_index   index.php;
24                 fastcgi_param   SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
25                 include         fastcgi_params;
26         }
27 
28         location = /favicon.ico {
29                 log_not_found off;
30                 access_log off;
31         }
32 }

 

posted @ 2017-06-28 14:59  L狗哥  阅读(728)  评论(0编辑  收藏  举报