码迷,mamicode.com
首页 > 其他好文 > 详细

nginx 80和443同时做负载均衡

时间:2018-08-08 19:52:59      阅读:582      评论:0      收藏:0      [点我收藏+]

标签:_for   pre   http   lis   oca   server   eal   crt   proxy   

nginx 80和443同时做负载均衡:

vi /etc/nginx/conf.d/default.conf

upstream bugqa.ming.com {
server 10.0.0.3:80;
server 10.0.0.4:80;
}

server {
    listen 80;
    location / {
             proxy_pass http://bugqa.ming.com;
             proxy_set_header  Host    $host;
             proxy_set_header  X-Real-IP  $remote_addr;
             proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
               }

                      server {
    listen 443;

             ssl on;
     ssl_certificate ming.com/ming.crt;
     ssl_certificate_key ming.com/ming.key;

    location / {
             proxy_pass http://bugqa.ming.com;
             proxy_set_header  Host    $host;
             proxy_set_header  X-Real-IP  $remote_addr;
             proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
               }             

:wq

service nginx restart

验证:

浏览器访问http://bugqa.ming.com 和 https://bugqa.ming.com

nginx 80和443同时做负载均衡

标签:_for   pre   http   lis   oca   server   eal   crt   proxy   

原文地址:http://blog.51cto.com/yangzhiming/2156469

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!