zoukankan      html  css  js  c++  java
  • Nginx配置TCP服务负载均衡

    # Nginx配置TCP服务负载均衡


    ## 前置条件

    - nginx 1.18 (1.9之后支持tcp负载)
    - 两个前置服务


    ## 配置文件修改

    Legacy
    Stable

    ```
    # cat nginx.conf
    user  nginx;
    # 增加工作线程
    worker_processes  4;

    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;


    events {
        # worker_connections  1024;
        # 工作者连接
        worker_connections 8192;
    }


    http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;

        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  /var/log/nginx/access.log  main;

        sendfile        on;
        #tcp_nopush     on;

        keepalive_timeout  65;

        #gzip  on;

        include /etc/nginx/conf.d/*.conf;
    }

    worker_rlimit_nofile 40000;

    stream {
        upstream appkey01 {
            least_conn;
            # server 192.168.1.14:9905 max_fails=3 fail_timeout=5s;
            server 192.168.1.192:9905 max_fails=3 fail_timeout=5s;
        }

        server {
            listen 9905;
            proxy_pass appkey01;
        }
    }
    ```

  • 相关阅读:
    3、二进制的秘闻和不同进制间的转换
    Hello World!
    HDU5883 The Best Path(欧拉回路 | 通路下求XOR的最大值)
    Codeforces 722C(并查集 + 思维)
    Floyd 算法求多源最短路径
    vim 配置
    STL容器 -- Vector
    STL容器 -- Bitset
    HDU 5707 Combine String(动态规划)
    HDU 5876 Sparse Graph(补图上BFS)
  • 原文地址:https://www.cnblogs.com/jiftle/p/13049899.html
Copyright © 2011-2022 走看看