1.正常只需要修改conf中server即可实现代理功能
server {
listen 80; #监听端口
server_name: localhost;
root /home; #访问目录
index index.html index.htm;
location / { #根目录默认跳转
index index.html index.htm;
}
}
2.添加ssl
server {
listen 443;
server_name www.baidu.com; #域名
root /home;
index index.html index.htm;
ssl on;#开启ssl
ssl_certificate 1_www.baidu.com_bundle.crt; #配置ssl证书
ssl_certificate_key 2_www.baidu.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 / {
index index.html index.htm;
}
}
若想支持默认http转https,可进行添加如下配置
server {
listen 80;
server_name www.baidu.com;
#http强制跳转https
rewrite ^(.*)host$request_uri permanent;
}
- 添加负载均衡