温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么通过nginx负载均衡跳转https

发布时间:2022-04-27 14:09:44 来源:亿速云 阅读:152 作者:iii 栏目:大数据

今天小编给大家分享一下怎么通过nginx负载均衡跳转https的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。

web端拷贝证书与密钥

   scp -rp -p52113 /application/nginx/conf/key 10.0.0.5:/application/nginx/conf/

在nginx负载均衡服务端配置

vim /application/nginx/conf/nginx.conf

worker_processes 2;
error_log logs/error.log;
events {
  worker_connections 65535;
}
http {
  include    mime.types;
  default_type application/octet-stream;
  sendfile    on;
  keepalive_timeout 65;
 
 
  upstream server_pools {
    server 10.0.0.200:443 weight=1 max_fails=3 fail_timeout=10;
    #server 10.0.0.8:443 weight=1 max_fails=3 fail_timeout=10;
    #server 10.0.0.9:443 weight=1 max_fails=3 fail_timeout=10;
  }
 
  server {
    listen    80;
    server_name localhost;
    rewrite ^(.*)$ https://$host$1 permanent;
  }
  server {
    listen 10.0.0.5:443;
    server_name www.abc.com;
 
    #开启 https 注意要添加在server区块 不能在http区块中放置
    ssl on;
    ssl_certificate /application/nginx/conf/key/server.crt;
    ssl_certificate_key /application/nginx/conf/key/server.key;
 
    location / {
      proxy_pass https://server_pools;
      proxy_set_header host $host;
      proxy_set_header x-forwarded-for $remote_addr;
    }
  }
}

#检查nginx负载均衡配置

   /application/nginx/sbin/nginx -t

#重启nginx负载均衡

   /application/nginx/sbin/nginx -s stop
   /application/nginx/sbin/nginx

浏览器访问测试

注意修改hosts对应的是负载均衡的ip地址信息

访问测试

怎么通过nginx负载均衡跳转https

访问结果

怎么通过nginx负载均衡跳转https

以上就是“怎么通过nginx负载均衡跳转https”这篇文章的所有内容,感谢各位的阅读!相信大家阅读完这篇文章都有很大的收获,小编每天都会为大家更新不同的知识,如果还想学习更多的知识,请关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI