全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

IP归属甄别会员请立即修改密码
查看: 1361|回复: 1
打印 上一主题 下一主题

[已解决] haproxy如何实现中转ws

[复制链接]
跳转到指定楼层
1#
发表于 2022-2-2 23:37:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 jarmoku 于 2022-2-3 01:12 编辑

以下是我目前的代码
  1. global
  2.         log /dev/log        local0
  3.         log /dev/log        local1 notice
  4.         chroot /var/lib/haproxy
  5.         stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
  6.         stats timeout 30s
  7.         user haproxy
  8.         group haproxy
  9.         daemon

  10.         # Default SSL material locations
  11.         ca-base /etc/ssl/certs
  12.         crt-base /etc/ssl/private

  13.         # See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate
  14.         ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
  15.         ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
  16.         ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets

  17. defaults
  18.         log        global
  19.         mode        http
  20.         option        httplog
  21.         option        dontlognull
  22.         timeout connect 5000
  23.         timeout client  50000
  24.         timeout server  50000
  25.         errorfile 400 /etc/haproxy/errors/400.http
  26.         errorfile 403 /etc/haproxy/errors/403.http
  27.         errorfile 408 /etc/haproxy/errors/408.http
  28.         errorfile 500 /etc/haproxy/errors/500.http
  29.         errorfile 502 /etc/haproxy/errors/502.http
  30.         errorfile 503 /etc/haproxy/errors/503.http
  31.         errorfile 504 /etc/haproxy/errors/504.http

  32. frontend http_frontend
  33.     mode http
  34.     option httplog
  35.     bind *:31006
  36.     option forwardfor
  37.     acl host_sjc hdr_beg(host) -i sjc.com
  38.     acl host_tyo hdr_beg(host) -i tyo.com

  39.     use_backend http_sjc if host_sjc
  40.     use_backend http_tyo if host_tyo

  41. backend http_sjc
  42.     mode http
  43.     option httplog
  44.     option forwardfor
  45.     server sjc 029.NA.POP.BIGAIRPORT.NET:12356

  46. backend http_tyo
  47.     mode http
  48.     option httplog
  49.     option forwardfor
  50.     server tyo 024.AP.POP.BIGAIRPORT.NET:12356
复制代码
2#
发表于 2022-2-3 00:38:10 | 只看该作者
我是这么转wss的,ws的你可以把ssl的去掉试试 我没试过
  1. frontend pf_http_in
  2.         bind :::2082
  3.         bind :::2083 ssl crt /etc/haproxy/cert.pem

  4.         acl pf_http_00_in hdr_beg(host) -i 域名1
  5.         acl pf_http_01_in hdr_beg(host) -i 域名2

  6.         use_backend pf_http_00_out if pf_http_00_in
  7.         use_backend pf_http_01_out if pf_http_01_in
  8.         use_backend pf_http_00_out if { ssl_fc_sni -i 域名1 }
  9.         use_backend pf_http_01_out if { ssl_fc_sni -i 域名2 }
  10.         default_backend pf_http_00_out

  11. backend pf_http_00_out
  12.         mode tcp
  13.         #mode http
  14.         #option forwardfor
  15.         #balance source
  16.         #timeout server 60s
  17.         #option httpchk HEAD /
  18.         server proxy00 落地IP:端口 maxconn 204800 ssl verify none

  19. backend pf_http_01_out
  20.         mode tcp
  21.         server proxy00 落地IP:端口 maxconn 204800 ssl verify none
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-12-24 01:02 , Processed in 0.058652 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表