zoukankan      html  css  js  c++  java
  • ginx *负载均衡配置多个域名同一端口

    现在有端口9006 负载均衡了二台虚拟机的二个端口:9006和9016二个端口共四个负载,任何一个有问题都不会影响系统访问,现在有二个域名和一个IP都要指向这个站点,Nginx中的配置如下:

    nginx.conf配置如下

    #user  nobody;
    worker_processes  1;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
        client_max_body_size 50m;
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
    
        access_log  logs/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
    
        #gzip  on;
    
    
        upstream webBO9006{
            #ip_hash;默认将按IP自动轮询方式
            server 192.168.8.1:9006;
            server 192.168.8.1:9016;#不同端口
            server 192.168.8.2:9006;#不同IP
            server 192.168.8.2:9016;
        }
        server {
            listen       9006;
            server_name  a.qq.com b.qq.com 122.122.122.122;
    
            location / {
                proxy_pass http://webBO9006;#一定要和upstream后面名字一样
                proxy_hide_header Set-Cookie;
                proxy_set_header Host $host:$server_port;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header REMOTE-HOST $remote_addr;
            }
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }
    
    }
        


    欢迎加入JAVA技术交流QQ群:179945282

    欢迎加入ASP.NET(C#)交流QQ群:17534377


  • 相关阅读:
    阿里云图片在线处理
    下载文件
    adobe acrobat dc根据模板制作PDF问题总结点
    springcloud服务进行轮询采用Ribbon
    SpringCloud-Eureka-Client 启动后自动停止
    OI模板
    化学整理
    题解 P4180 [BJWC2010]严格次小生成树
    题解 CF255D 【Mr. Bender and Square】
    题解 P1541 【乌龟棋】
  • 原文地址:https://www.cnblogs.com/q149072205/p/15482009.html
Copyright © 2011-2022 走看看