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


  • 相关阅读:
    和我一起看API(一)你所不知道的LinearLayout补充
    SQLSERVER常见系统函数之字符串函数(一)
    C#使用ADO.NET访问数据库(一)
    SQLSERVER基础语句(一)
    Vue 项目部署之iis
    XiaoQi.Study 之 .net core webapi (三)
    XiaoQi.Study 之 .net core webapi (二)
    XiaoQi.Study 之.net core webapi(一)
    Vue 学习笔记(四)
    Vue 学习笔记(二)
  • 原文地址:https://www.cnblogs.com/q149072205/p/15482009.html
Copyright © 2011-2022 走看看