Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Url HAProxy 1.5-使用映射将路径链接到后端_Url_Proxy_Configuration_Haproxy - Fatal编程技术网

Url HAProxy 1.5-使用映射将路径链接到后端

Url HAProxy 1.5-使用映射将路径链接到后端,url,proxy,configuration,haproxy,Url,Proxy,Configuration,Haproxy,基本上,正如标题所示。我试图简化HAProxy配置文件,并了解了map函数。现在,我正在尝试将其设置为匹配到特定后端的路径。文件的原始设置如下所示: #This is a cleaned up version, as I'm not comfortable putting actual paths and server names online #That said, this is the same basic format frontend http maxconn 2000 bi

基本上,正如标题所示。我试图简化HAProxy配置文件,并了解了
map
函数。现在,我正在尝试将其设置为匹配到特定后端的路径。文件的原始设置如下所示:

#This is a cleaned up version, as I'm not comfortable putting actual paths and server names online
#That said, this is the same basic format

frontend http
  maxconn 2000
  bind 0.0.0.0:5110

  acl employee-webserver path_reg -i /test/employee/.* 
  use_backend servers-employee-webserver if employee-webserver 

  acl employee-internal_api path_reg -i /test/internal_api/employee/.* 
  use_backend servers-employee-internal_api if employee-internal_api

backend servers-employee-webserver 
  balance leastconn
  cookie TEST insert 
  http-request set-header X-Forwarded-Proto https if { ssl_fc }
  server server1.test.com 127.0.0.1:9000 cookie S1 check inter 30s fall 1 rise 1 

backend servers-employee-internal_api 
  balance leastconn  
  cookie TEST insert
  reqrep ^(.+)\ /test/internal_api/employee/(.*?$) \1\ /\2
  server server1.test.com 127.0.0.1:8000 cookie S1 check inter 30s fall 1 rise 1 

所讨论的服务有多个部分、客户端使用的Web服务器和内部API。我们还有其他使用相同设置的服务,它们将位于此文件中

我发现我可以使用映射文件来简化此过程,将相应后端的路径和名称提取到一个单独的文件中:

frontend http
  maxconn 2000
  bind 0.0.0.0:5110

  use_backend bk_%[base,map_beg(/apps/haproxy/config/haproxy.map)]

backend servers-employee-webserver 
  balance leastconn
  cookie TEST insert 
  http-request set-header X-Forwarded-Proto https if { ssl_fc }
  server server1.test.com 127.0.0.1:9000 cookie S1 check inter 30s fall 1 rise 1 

backend servers-employee-internal_api 
  balance leastconn  
  cookie TEST insert
  reqrep ^(.+)\ /test/internal_api/employee/(.*?$) \1\ /\2
  server server1.test.com 127.0.0.1:8000 cookie S1 check inter 30s fall 1 rise 1 

其中,映射文件haproxy.map为:

server1.test.com:5110/test/employee servers-employee-webserver
server1.test.com:5110/test/internal_api/employee servers-employee-internal_api 

但是,当我进入代码> Serv1.1. Test.com:5110 /测试/雇员/home < /C>时,我仍然有503的错误,当我的理解是密钥<代码> Serv1.Test.com:5110 /Test/Engult应该把它看作是一个有效的映射。我尝试删除服务器名称,这样我就只有路径了,我尝试了包括协议(http),我尝试了在路径的末尾添加一个通配符。这些都没有产生任何影响

  • 我的地图文件有什么问题?这是haproxy 1.5的功能吗
  • 如果我能让它正常工作,我将在DNS,
    employee\u service.company.com
    后面托管haproxy实例,它将指向端口5110上的haproxy。我假设我必须用完成的DNS名称替换映射文件中的服务器名称。对吗
  • 如果每个后端都需要一个cookie、一个X-Forwarded Proto头,并且具有不同的regrep,那么是否可以使用映射文件对后端进行类似的设置

  • 尝试删除use_backend keywork中的
    bk_
    前缀。如果这还不够,您还可以登录
    %[base]
    ,查看haproxy如何为您的请求构建此示例;2.您需要更改dns部分或使用
    路径
    获取样本;3.请用一个例子详细说明一下。尝试删除use_backend keywork中的
    bk_
    前缀。如果这还不够,您还可以登录
    %[base]
    ,查看haproxy如何为您的请求构建此示例;2.您需要更改dns部分或使用
    路径
    获取样本;3.请举例说明。