服务器 
首页 > 服务器 > 浏览文章

如何通过nginx负载均衡跳转https

(编辑:jimmy 日期: 2024/5/9 浏览:3 次 )

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

上一篇:解决docker pull被复位出现的问题
下一篇:如何Docker化Python Django应用程序
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网