Nginx 配置 HTTPS

  • 配置文件基本如下,请参考并进行相应的修改
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
server
{
listen 80;
server_name domain.example.com ; #修改为自己的域名
rewrite ^(.*)`$ https://$`host$1 permanent;
}

server {
listen 443;
server_name domain.example.com; #修改为自己的域名
ssl on;
root html; #html修改为网站的对应路径
index index.html index.htm;
ssl_certificate cert/yourcrt.pem; #将证书添加到相应的文件夹
ssl_certificate_key cert/yourkey.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 / {
root html; #html修改为网站的对应路径
index index.html index.htm;
}
}