步骤1.配置nginx.conf文件,调用*.conf文件夹内容
cat nginx.conf
include /etc/nginx/conf.d/*.conf;
步骤2.*.conf文件夹下创建配置文件,如下
例:以www.xxx.com域名为例,将http替换为https:
原配置:
server {
listen 80;
server_name www.xxx.com;
include /etc/nginx/conf.d/http-proxy-xff.conf;
#access_log /var/log/nginx/www.xxx.com.access.log main;
location / {
proxy_pass http://10.100.3.79;
limit_except GET POST {
deny all;
}
}
}
替换内容如下:
server {
listen 80;
server_name www.xxx.com;
include /etc/nginx/conf.d/http-proxy-xff.conf;
access_log /var/log/nginx/www.xxx.com.access.log main;
if ($host ~* www.xxx.com) {
rewrite ^(.*)$ https://$host$1 permanent;
}
}
server {
listen 443;
server_name www.xxx.com;
ssl on;
ssl_certificate /etc/ssl/xxx.cer; # 公钥文件(Globalsign 颁发的证书)
ssl_certificate_key /etc/ssl/xxx.com.key; # 私钥文件
access_log /var/log/nginx/httpswww.xxx.com.access.log main;
include /etc/nginx/conf.d/https-proxy-xff.conf;
location / {
proxy_pass http://10.100.3.79;
}
}