nginx 配置4层代理

栏目: 服务器 · Nginx · 发布时间: 5年前

内容简介:nginx-1.9.0 开始支持 TCP 代理,也就是4层代理,默认编译不会支持,需要加上 –with-stream 参数编译。进入 nginx 目录编译

nginx-1.9.0 开始支持 TCP 代理,也就是4层代理,默认编译不会支持,需要加上 –with-stream 参数编译。

NGINX 编译

进入 nginx 目录

cd /home/fwj/nginx-1.15.9

编译

./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream

配置 nginx.conf

user  www www;
worker_processes  1;


events {
    worker_connections  1024;
}

stream{
    log_format proxy '$remote_addr [$time_local] '
                 '$protocol $status $bytes_sent $bytes_received '
                 '$session_time "$upstream_addr" '
                 '"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
    open_log_file_cache off;
    access_log logs/tcp-access.log proxy ;
    upstream test{
        server 127.0.0.1:666  weight=1 max_fails=1 fail_timeout=30s;
    }
    server{
        listen 60;
        proxy_pass test;
        proxy_connect_timeout 8s;
        proxy_timeout 7d;
    }
}

执行

./nginx -c /usr/local/nginx/conf/nginx.conf

查看日志

# cat tcp-access.log
192.168.10.202 [06/Mar/2019:12:35:30 +0800] TCP 200 615 749 5.170 "127.0.0.1:666" "749" "615" "0.000"
192.168.10.202 [06/Mar/2019:12:36:07 +0800] TCP 200 246 419 5.008 "127.0.0.1:666" "419" "246" "0.000"
192.168.10.202 [06/Mar/2019:12:38:50 +0800] TCP 200 0 0 0.000 "127.0.0.1:666" "0" "0" "0.000"

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Computational Geometry

Computational Geometry

Mark de Berg、Otfried Cheong、Marc van Kreveld、Mark Overmars / Springer / 2008-4-16 / USD 49.95

This well-accepted introduction to computational geometry is a textbook for high-level undergraduate and low-level graduate courses. The focus is on algorithms and hence the book is well suited for st......一起来看看 《Computational Geometry》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具