您的位置:首页 > 理论基础 > 计算机网络

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

2018-09-23 15:40 901 查看

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+Tomcat+Https 服务器负载均衡配置实践方案详解 nginx 作为反向代理实现负载均衡的例子 Nginx负载均衡的4种方案配置实例 windows安装nginx部署步骤图解(反向代理与负载均衡) Nginx+Windows负载均衡配置方法 windows使用nginx实现网站负载均衡测试实例 Nginx 安装笔记(含PHP支持、虚拟主机、反向代理负载均衡) Nginx实现根据域名http、https分发配置示例 Nginx出现The plain HTTP request was sent to HTTPS port问题解决方法 详解Nginx服务器中配置全站HTTPS安全连接的方法 Nginx搭建HTTPS服务器和强制使用HTTPS访问的方法
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx 负载均衡 https