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
    
  • 相关阅读:
    mysql中的round函数的使用
    mysql中日期函数的处理,datediff()函数 与 timestampdiff()函数的区别 及使用。
    easyui datagrid 自定义editor
    好的产品 跟 好的 设计师 很类似
    music
    gd库复制图片做水印
    用gd库画矩形和椭圆
    默认安装wamp修改MySQL密码
    中文验证码
    验证码
  • 原文地址:https://www.cnblogs.com/kylingx/p/11890046.html
Copyright © 2011-2022 走看看