AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 417597
Accepted
Sam Saffron
Sam Saffron
Asked: 2012-08-15 16:12:18 +0800 CST2012-08-15 16:12:18 +0800 CST 2012-08-15 16:12:18 +0800 CST

haproxy 可以用来平衡 unix 套接字吗?

  • 772

在 nginx 中,将其配置为代理 unix.sock文件相当简单

例如:

upstream bla {
      server unix:///home/sam/Source/bla/tmp/sockets/thin1.sock;
      server unix:///home/sam/Source/bla/tmp/sockets/thin2.sock;
 }

.sockhaProxy中是否有类似的语法来启用平衡本地文件?

haproxy
  • 3 3 个回答
  • 11576 Views

3 个回答

  • Voted
  1. Best Answer
    Alexander
    2014-09-22T22:51:19+08:002014-09-22T22:51:19+08:00

    简短回答:是的,从 1.5 版开始。

    让我们看一下服务器关键字参数文档:

    <address> is the IPv4 or IPv6 address of the server. Alternatively, a
              resolvable hostname is supported, but this name will be resolved
              during start-up. Address "0.0.0.0" or "*" has a special meaning.
              It indicates that the connection will be forwarded to the same IP
              address as the one from the client connection. This is useful in
              transparent proxy architectures where the client's connection is
              intercepted and haproxy must forward to the original destination
              address. This is more or less what the "transparent" keyword does
              except that with a server it's possible to limit concurrency and
              to report statistics. Optionally, an address family prefix may be
              used before the address to force the family regardless of the
              address format, which can be useful to specify a path to a unix
              socket with no slash ('/'). Currently supported prefixes are :
                    - 'ipv4@'  -> address is always IPv4
                    - 'ipv6@'  -> address is always IPv6
                    - 'unix@'  -> address is a path to a local unix socket
                    - 'abns@'  -> address is in abstract namespace (Linux only)
              Any part of the address string may reference any number of
              environment variables by preceding their name with a dollar
              sign ('$') and optionally enclosing them with braces ('{}'),
              similarly to what is done in Bourne shell.
    

    因此,您可以使用前导斜杠指定 unix 套接字的路径,或者显式地添加地址族前缀:

    server nginx1 /run/nginx/default.sock
    server nginx2 [email protected]
    
    • 15
  2. Stone
    2012-08-15T21:01:26+08:002012-08-15T21:01:26+08:00

    正如 quanta 所说,它需要 IPv4 地址,但是使用socat将 unix scoket 中继到 TCP,也许你可以使用 HAProxy。

    socat TCP-LISTEN:1234,reuseaddr,fork UNIX-CLIENT:/tmp/foo
    
    • 3
  3. quanta
    2012-08-15T20:55:11+08:002012-08-15T20:55:11+08:00

    AFAIK,HAProxy 不支持它。根据文档,您必须指定服务器的 IPv4 或 IPv6(或主机名)。

    • 0

相关问题

  • 具有动态路由的代理服务器

  • nginx 访问日志忽略某些请求

  • HAProxy 和“分片”

  • 带有 HAProxy 的远程 IP

  • SSL 网站的高可用性

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve