Nginx

刮开看看:这里只有一个面试题

nginx 配置 https

配置 ssl 证书,然后重定向到 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
25
http{

server{
listen 443 ssl;
#对应你的域名
server_name calyee.cn;
ssl_certificate /usr/local/nginx/cert/ssl.crt;
ssl_certificate_key /usr/local/nginx/cert/ssl.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
#如果是静态文件,直接指向目录,如果是动态应用,用proxy_pass转发一下
location / {
root /usr/local/service/ROOT;
index index.html;
}
}
#监听80端口,并重定向到443
server{
listen 80;
server_name calyee.cn;
rewrite ^/(.*)$ https://calyee.cn:443/$1 permanent;
}
}