• 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
    
  • 相关阅读:
    物理分页和逻辑分页扫盲
    JAVA集合操作的利器:CollectionUtils
    关于MYSQL表记录字段换行符回车符处理
    JSONObject依赖包
    Spring Mvc中@ResponseBody中文乱码解决,以及修改返回的Content-Type
    Python运行出错情况
    Python编码相关理解
    Python访问Access数据库
    Python
    android开发(1)
  • 原文地址:https://www.cnblogs.com/kylingx/p/11890046.html
Copyright © 2020-2023  润新知