zoukankan      html  css  js  c++  java
  • Centos610-Nginx-TCP代理配置

    1.安装Nginx

      详见《nginx》安装

    2.下载nginx_tcp_proxy_module模块

      下载  wget https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master.zip

      解压 unzip master.zip

      

           进入nginx源码目录 cd ncd /opt/download/nginx-1.9.9

      清空上次编译 make clean

      修改文件 vi ../nginx_tcp_proxy_module-master/ngx_tcp_upstream.h  

        144行:ngx_resolver_addr_t --> ngx_addr_t

      打补丁  patch -p1 < /opt/download/nginx_tcp_proxy_module-master/tcp.patch 根据提示输入y 回车

      执行结果  

    patching file src/core/ngx_log.c
    Hunk #1 FAILED at 66.
    1 out of 1 hunk FAILED -- saving rejects to file src/core/ngx_log.c.rej
    patching file src/core/ngx_log.h
    Hunk #1 FAILED at 29.
    Hunk #2 FAILED at 37.
    2 out of 2 hunks FAILED -- saving rejects to file src/core/ngx_log.h.rej
    patching file src/event/ngx_event_connect.h
    Hunk #1 succeeded at 33 (offset 1 line).
    Hunk #2 succeeded at 44 with fuzz 2 (offset 1 line).

      生成编译 ./configure --with-http_stub_status_module  --add-module=../nginx_tcp_proxy_module-master --with-stream

      结果:

        

        编译 make

        升级 make upgrade      

    3.复制编译文件

      进入目录 cd /opt/download/nginx-1.9.9/objs

      拷贝文件 cp nginx /usr/local/nginx/sbin/

    4.验证模块添加结果

      service nginx restart

      

       启动完成,说明nginx_tcp_proxy_module添加完成。

    5.添加tcp配置

     cd /usr/local/nginx/conf

     mkdir tcpconfigs

     vi nginx.conf 在http{} 前面添加如下配置 

    tcp{
        timeout 1d;
        proxy_read_timeout 10d;
        proxy_send_timeout 10d;
        proxy_connect_timeout 30;
        include tcpconfigs/*.conf;    
    }

      cd /tcpconfigs

      vi dfs_tracker.conf 插入如下代码配置

    upstream fdfs_tracker {
             server 192.168.125.155:22122;
             check interval=3000 rise=2 fall=5 timeout=1000;
        }
    server {
            listen  9011;
            proxy_pass fdfs_tracker;
            #so_keepalive on;
            #tcp_nodelay on;
    }

       保存退出

    6.添加header传值支持

      underscores_in_headers on;

      

     7.重启nginx

     service nginx restart

     

      启动完成。

     

     

      

      

  • 相关阅读:
    MongoDB分片集群还原
    集群因子(Clustering Factor)
    Sunisoft.IrisSkin.SkinEngine 设置winform皮肤
    17monipdb根据IP获得区域
    ArraySegmentSample
    RichTextBox指定全部文字显示不同颜色及部分文字高亮颜色显示
    Git 基本分支规范
    C# 获取方法内参数名称
    (转)C#中的Predicate<T>与Func<T, bool>
    EF 多线程TransactionScope事务异常"事务EFTransaction类定义:与另一个进程被死锁在 锁 资源上,并且已被选作死锁牺牲品。请重新运行该事务。"
  • 原文地址:https://www.cnblogs.com/oumi/p/12105171.html
Copyright © 2011-2022 走看看