nginx 80和443同时做负载均衡

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

猜你喜欢

转载自blog.51cto.com/yangzhiming/2156469