Nginx实现强制https连接

修改Nginx配置文件

../nginx/sites-available/default

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
server {
listen 443;
server_name *.com;
ssl on;
root /var/www/GitBook;

index index.html index.php index.htm;<!--more-->
ssl_certificate cert/*.com.pem;
ssl_certificate_key cert/*.com.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;

location / {
try_files $uri $uri/ =404;
}

location ~ /\.ht {
deny all;
}

}

server {
listen 80;
listen [::]:80;

server_name *.com;

rewrite ^(.*)$ https://$host$1 permanent;

}

在sites-enabled建立软连接:

ln -s ../sites-available/fetdesign_tcm