-
Notifications
You must be signed in to change notification settings - Fork 421
/
CDN_nginx.conf
70 lines (60 loc) · 3.04 KB
/
CDN_nginx.conf
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#使用多个域名实现CDN应用与正常应用共存配置
#一、多个域名使用同一个通配符证书或SAN证书
#原配置参数:
#.........<省略>........
server {
listen 443 ssl; #IPv4,https默认监听端口。
listen [::]:443 ssl; #IPv6,https默认监听端口。无IPv6,此项可以删除。
server_name xx.yy; #修改成自己的域名
ssl_certificate /home/tls/xx.yy/xx.yy.crt; #换成自己的证书,绝对路径。
ssl_certificate_key /home/tls/xx.yy/xx.yy.key; #换成自己的密钥,绝对路径。
#.........<省略>........
}
}
#以上参数修改如下:
#.........<省略>........
server {
listen 443 ssl; #IPv4,https默认监听端口。
listen [::]:443 ssl; #IPv6,https默认监听端口。无IPv6,此项可以删除。
server_name *.xx.yy; #限定域名访问(禁止以ip方式访问网站),更改为自己的域名。
ssl_certificate /home/tls/wildcard_.xx.yy/wildcard_.xx.yy.crt; #换成自己的通配符证书或SAN证书,绝对路径。
ssl_certificate_key /home/tls/wildcard_.xx.yy/wildcard_.xx.yy.key; #换成自己的通配符密钥或SAN密钥,绝对路径。
#.........<省略>........
}
}
#注意:
#1、如多个域名使用同一个SAN证书,配置与上使用通配符证书配置类似,只是上述的通配符域名调整为多个域名。
#二、多个域名使用各自普通证书
#原配置参数:
#.........<省略>........
server {
listen 443 ssl; #IPv4,https默认监听端口。
listen [::]:443 ssl; #IPv6,https默认监听端口。无IPv6,此项可以删除。
server_name xx.yy; #修改成自己的域名
ssl_certificate /home/tls/xx.yy/xx.yy.crt; #换成自己的证书,绝对路径。
ssl_certificate_key /home/tls/xx.yy/xx.yy.key; #换成自己的密钥,绝对路径。
#.........<省略>........
}
}
#以上参数修改如下:
#.........<省略>........
server {
listen 443 ssl; #IPv4,https默认监听端口。
listen [::]:443 ssl; #IPv6,https默认监听端口。无IPv6,此项可以删除。
server_name z1.xx.yy; #修改成自己的域名
ssl_certificate /home/tls/z1.xx.yy/z1.xx.yy.crt; #换成自己的证书,绝对路径。
ssl_certificate_key /home/tls/z1.xx.yy/z1.xx.yy.key; #换成自己的密钥,绝对路径。
#.........<省略>........
}
server {
listen 443 ssl; #IPv4,https默认监听端口。
listen [::]:443 ssl; #IPv6,https默认监听端口。无IPv6,此项可以删除。
server_name z2.xx.yy; #修改成自己的域名
ssl_certificate /home/tls/z2.xx.yy/z2.xx.yy.crt; #换成自己的证书,绝对路径。
ssl_certificate_key /home/tls/z2.xx.yy/z2.xx.yy.key; #换成自己的密钥,绝对路径。
#.........<省略>........
}
}
#注意:
#1、此示例必须 nginx 带 stream_ssl_preread_module 模块,即 SNI 分流模块。
#2、z1.xx.yy与z2.xx.yy表示两个不同域名(推荐采用根域名相同的两个二级域名即可)。