nginx作为负载,配置SSL证书的配置如下
# 订单下4台服务器进行轮训
upstream order.haoshang.com{
server 59.110.170.42:8091;
server 59.110.172.46:8091;
server 59.110.178.49:8091;
server 59.110.125.145:8091;
}
server {
#监听端口设置为443 ssl
listen 443 ssl;
server_name order.haoshang.com;
#将购买的ssl证书放入liunx指定目录/home/soft/nginx-1.20.2/conf/cert
ssl_certificate /home/soft/nginx-1.20.2/conf/cert
gzip_http_version 1.1;
gzip_comp_level 3;
gzip_types text/plain application/javascript application/css text/css application/xml text/javascript image/jpeg image/gif image/png application/x-font-truetype application/x-font-woff;
gzip_vary off;
gzip_disable "MSIE [1-6]\.";
root /bigdata/supplier-portal/dist/;
index index.html index.htm;
client_max_body_size 50m;
location /api/ {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://order.haoshang.com/;
}
location / {
rewrite ^/.*/$ / last;
rewrite ^([^.]*[^/])$ $1/ permanent;
}
}
如果使用了阿里云SLB作为负载配置SSL证书,nginx无需配置SSL证书的配置如下
# haoshang.com下两台服务器进行轮训
upstream haoshang.com{
server 172.22.76.29:8300;
server 172.22.76.99:8300;
}
server {
listen 80;
server_name haoshang.com;
location / {
# proxy_store off;
# proxy_redirect off;
# 把 https 的协议告知 Tomcat,否则 Tomcat 可能认为是 http 的请求
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Referer 'no-referrer-when-downgrade';
# proxy_set_header User-Agent 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36';
proxy_pass http://haoshang.com;
}
}