Haproxy-nginx-SSH -tcp代理

编译参数

--prefix=/usr/local/nginx --with-pcre --user=daemon --group=daemon --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-stream --with-http_gzip_static_module
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


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"'
				 '$remote_addr $remote_port';

      map $bytes_received $loggable {
       0 0;
       default 1;
    }

    access_log /usr/local/nginx/logs/tcp-access.log proxy if=$loggable;
    open_log_file_cache off;

    upstream backend {
       server 8.132.3.23:2222;

    }

    server {

        listen 12236;

        proxy_pass backend;

    }

}

HAproxy

###########全局配置#########
 
global
 
daemon  #以后台形式运行harpoxy
 
nbproc 1  #设置进程数量
 
pidfile /usr/local/haproxy/conf/haproxy.pid  #进程PID文件
 
 
 
########默认配置############
 
defaults
 
    mode tcp   #设置HAProxy默认的工作模式,有tcp,http,health三种
 
    retries 2   #两次连接失败就认为是服务器不可用,也可以通过后面设置
 
    option redispatch #当serverId对应的服务器挂掉后,强制定向到其他健康的服务器,以后将不支持
 
    option abortonclose  #当服务器负载很高的时候,自动结束掉当前队列处理比较久的链接
 
    timeout connect 5000ms  #连接超时
 
    timeout client 30000ms   #客户端超时
 
    timeout server 30000ms  #服务器超时
 
    timeout check 2000      #心跳检测超时
 
    log 127.0.0.1 local0 err
 
listen http_front #haproxy的客户页面
  bind 0.0.0.0:18888
  mode http
  option httplog
  stats uri /haproxy
  stats auth admin:12300admin
  stats refresh 5s
  stats enable
 
 
########统计页面配置########
 
listen test1   #这里是配置负载均衡,test1是名字,可以任意
   option forwardfor 
    bind 0.0.0.0:12348  #这里是监听的IP地址和端口,端口号可以在0-65535之间,要避免端口冲突
 
 
 
    mode tcp  #连接的协议,这里是tcp协议
 
    server s1  192.168.8.12:5222
systemctl status haproxy 
systemctl restart haproxy
将服务端13.159..23.9端口转发到本地电脑上18888端口上
ssh -L18888:127.0.0.1:18888 root@113.159..23.9

http://127.0.0.1:18888/haproxy
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值