nginx ssl 設定

這採用兩階段設定
第一步先拿到80 port 然後轉 443
話不多說 直接看設定檔

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
server {
  listen 80 ;
    server_name example.shop;
 
    # redirects both www and non-www to https
    return 301 https://$server_name$request_uri;
 
}
 
server {
 
    listen 443 ssl;
    server_name  example.shop;
 
    #ssl 設定
    ssl on;
    #ssl 認證 ,憑證中心發給的crt檔
    ssl_certificate /etc/nginx/ssl/example.shop.crt;
    #產生ssl的認證前 所使用的private key
    ssl_certificate_key /etc/nginx/ssl/example.shop.key;
    root   /var/www/public_html/;
    index  index.php index.html index.htm;
 
    error_log  /var/log/nginx/example.shop_error.log  warn;
 
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
 
    location ~ \.php$ {
        fastcgi_read_timeout 3600;
        fastcgi_pass   php-fpm-sock;
        fastcgi_index  index.php;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }
 
}

發佈留言