[nginx] socket转发

ngx_stream_core_module

The ngx_stream_core_module module is available since version 1.9.0. This module is not built by default, it should be enabled with the --with-stream configuration parameter. (不过貌似window不需要手动启)

events {
    worker_connections  1024;
}


http {
    ......
}

stream {
    # 添加socket转发的代理
    upstream qm_socket {
        hash $remote_addr consistent;
        # 转发的目的地址和端口
        server 114.80.166.240:3333 weight=5 max_fails=3 fail_timeout=30s;
        # max_fails=3  失败后尝试重连3次
        # fail_timeout=30s  3次都失败后,再次进行3次重连的间隔
    }

    # 提供转发的服务,即访问localhost:3222,会跳转至代理 qm_socket 指定的转发地址
    server {
       listen 3222;
       #proxy_connect_timeout 1s;
       #proxy_timeout 180s;  #不支持直接设置分钟。不设置的话貌似默认时间是30m?
       proxy_pass qm_socket;
    }
}

转载于:https://www.cnblogs.com/qingmingsang/articles/6826695.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值