阿里雲配置ssl證書


 

一、申請證書和下載證書(阿里雲申請)

 

二、在nginx服務器上配置ssl證書

1.檢查服務器是否安裝openssl

 

2.在nginx conf 文件夾創建 cret 文件,放置證書

[root@web conf]# mkdir cert

3.在需要的域名vhost主機下面配置ssl 

[root@web vhost]# vi 80.conf

 1 server {
 2     listen 80;
 3     server_name app.test.com;
 4 
 5     location / {
 6         root $root_path;
 7         index index.html index.htm index.php;
 8         if (!-e $request_filename) {
 9            # rewrite ^(.*)$ /index.php?s=/$1 last;
10                 rewrite ^/index.php(.*)$ /index.php?s=$1 last;
11          rewrite ^(.*)$ /index.php?s=$1 last;
12 
13         }
14     }
15     error_page 500 502 503 504 /50x.html;
16     location = /50x.html {
17         root $root_path;
18     }
19 
20     location ~ \.php$ {
21         root $root_path;
22         #fastcgi_pass 127.0.0.1:9000;
23                 fastcgi_pass unix:/tmp/php-cgi.sock;
24         fastcgi_index index.php;
25         include fastcgi.conf;
26     }
27 }
28 server {
29     listen 443;
30     server_name app.test.com;
31     ssl on;
32     ssl_certificate    /usr/local/nginx/conf/cert/21485836dsfdsf0846.pem;
33     ssl_certificate_key   /usr/local/nginx/conf/cert/214sdfdfds0846.key;
34     ssl_session_timeout 5m;
35     sl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
36     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
37     ssl_prefer_server_ciphers on;    
38     location / {
39         root $root_path;
40         index index.html index.htm index.php;
41         if (!-e $request_filename) {
42            # rewrite ^(.*)$ /index.php?s=/$1 last;
43                 rewrite ^/index.php(.*)$ /index.php?s=$1 last;
44          rewrite ^(.*)$ /index.php?s=$1 last;
45 
46         }
47     }
48     error_page 500 502 503 504 /50x.html;
49     location = /50x.html {
50         root $root_path;
51     }
52 
53     location ~ \.php$ {
54         root $root_path;
55         #fastcgi_pass 127.0.0.1:9000;
56                 fastcgi_pass unix:/tmp/php-cgi.sock;
57         fastcgi_index index.php;
58         include fastcgi.conf;
59     }
60     
61 }
View Code

 

4.檢查nginx 配置文件

5.重啟nginx 

nginx -s reload

 

三、效果

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM