nginx作为负载配置SSL证书

 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;

        }

    }

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值