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
  • 相关阅读:
    《逍遥法外》观后感
    1237. 螺旋折线
    P2196 挖地雷
    787. 归并排序
    466. 回文日期
    P1032 字串变换
    P1825 [USACO11OPEN]Corn Maze S
    P1162 填涂颜色
    P1101 单词方阵
    P1019 单词接龙
  • 原文地址:https://www.cnblogs.com/w787815/p/6682824.html
Copyright © 2011-2022 走看看