zoukankan      html  css  js  c++  java
  • nginx编译安装以及配置tcp转发

    依赖包安装

    yum -y install gcc gcc-c++ make automake autoconf pcre pcre-devel zlib zlib-devel openssl openssl-devel libtool
    

    编译安装

    cd /usr/share/dev/
    wget http://mirrors.sohu.com/nginx/nginx-1.16.1.tar.gz
    ./configure 
    --prefix=/etc/nginx                   
    --sbin-path=/usr/sbin/nginx           
    --conf-path=/etc/nginx/nginx.conf     
    --pid-path=/var/run/nginx.pid         
    --lock-path=/var/run/nginx.lock       
    --error-log-path=/var/log/nginx/error.log 
    --http-log-path=/var/log/nginx/access.log 
    --with-stream
    或者./configure --prefix=/data/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream
    make&&make install
    

    nginx启动以及关闭

    cd /sbin
    ./nginx
    ./nginx -s stop/reload
    

    测试配置文件

    nginx -t

    修改nginx.conf,配置tcp转发

    cd /etc/nginx
    vim nginx.conf
    stream {
    upstream tcp {
            server 10.66.34.20:3389;
            hash $remote_addr consistent;
        }
    server {
            listen 33890;
            proxy_connect_timeout 10s;
            proxy_timeout 60s;  
            proxy_pass tcp;
        }
    }
    

    配置UDP转发,位于stream下方

    stream {
    upstream tcp {
            server 10.66.34.20:3389;
            hash $remote_addr consistent;
        }
    server {
            listen 33890 udp reuseport;
            proxy_connect_timeout 10s;
            proxy_timeout 60s;  
            proxy_pass tcp;
        }
    }
    

    设置nginx开机启动

    vim /etc/rc.local
    增加一行 /usr/sbin/nginx
    chmod 755 rc.local
    
  • 相关阅读:
    for..of与for..in
    吉凶与祸福之辩证
    console.log(0.2+0.4===0.6)// true or false??
    Javascripte的原型链之基础讲解
    Vue之九数据劫持实现MVVM的数据双向绑定
    Object的方法
    Javscript的函数链式调用基础篇
    Object.keys
    Object.prototype.hasOwnProperty与Object.getOwnPropertyNames
    call和apply还有bind
  • 原文地址:https://www.cnblogs.com/kylingx/p/11890046.html
Copyright © 2011-2022 走看看