zoukankan      html  css  js  c++  java
  • Nginx四层代理

    Nginx支持四层代理

    http://nginx.org/en/docs/stream/ngx_stream_core_module.html

    ngx_stream_core_module模块自1.9.0版开始可用。默认情况下,此模块不构建,应使用配置参数启用 --with-stream 。

    [root@linux-node1 src]# tar xf nginx-1.10.3.tar.gz 
    [root@linux-node1 src]# cd nginx-1.10.3
    [root@linux-node1 nginx-1.10.3]# useradd -s /sbin/nologin -M www
    [root@linux-node1 nginx-1.10.3]# yum install gcc gcc-c++ zlib-devel pcre-devel openssl openssl-devel -y
    [root@linux-node1 nginx-1.10.3]# ./configure --prefix=/usr/local/nginx-1.10.3 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-stream
    [root@linux-node1 nginx-1.10.3]# make && make install 
    
    配置文件
    worker_processes  1;
    events {
        worker_connections  1024;
    }
    stream {  
            upstream tcp_proxy {
            hash $remote_addr consistent;  #远程地址做个hash
            server 192.168.230:131:22;
       }
          server {
            listen 2222;
            proxy_connect_timeout 1s;
            proxy_timeout 10s;  #后端连接超时时间
            proxy_pass tcp_proxy;
         }
      }
    
      
      [root@linux-node1 conf]# /usr/local/nginx-1.10.3/sbin/nginx 
      
      [root@linux-node1 conf]# netstat -ntpl|grep 2222
    tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      12045/nginx: master 
    
    
    
    
    [root@linux-node1 conf]# ssh -p 2222 root@192.168.230.130
    root@192.168.230.130's password: 
    Last login: Sat Apr  8 22:32:14 2017 from linux-node1
    [root@linux-node2 ~]# ls
    anaconda-ks.cfg  hello.py
  • 相关阅读:
    typescript-定义静态类型和对象类型
    typescript-全局安装
    Cube-ui的使用
    mobx-react
    Calatan Number
    快速排序
    Boyer-Moore
    优先级队列
    PointNet环境搭建
    h5py库
  • 原文地址:https://www.cnblogs.com/w787815/p/6682824.html
Copyright © 2011-2022 走看看