WSO2 APIM 网关正在将主机 header 设置为 host:port

WSO2 APIM gateway is setting Host header as host:port

A​​PIM 网关正在将主机 header 设置为 host:port 以调用后端,如下所示:

GET /api/category HTTP/1.1
Accept-Language: en-US,en;q=0.8,pt;q=0.6
token: 6785ea7b-#######-#######-93f06834660a
Accept-Encoding: gzip, deflate, sdch
X-Forwarded-Server: server01
X-Forwarded-For: 172.XX.XXX.XX
User-Agent: Mozilla/5.0 (X11; Linux x86_64)
Postman-Token: ece4261e-d610-655c-f06c-f24a99f007c8
Accept: /
X-Forwarded-Host: server01
Cache-Control: no-cache
Host: api.empresa.net:80
Connection: Keep-Alive

这会导致 Web 应用程序防火墙出现问题,我该如何更改? 环境:RedHat Linux 6.7,APIM 1.9.1

谢谢

根据 protocol specification

The Host request-header field specifies the Internet host and port number of the resource being requested, as obtained from the original URI given by the user or referring resource.

   Host = "Host" ":" host [ ":" port ] ; Section 3.2.2

A "host" without any trailing port information implies the default port for the service requested (e.g., "80" for an HTTP URL). For example, a request on the origin server for http://www.w3.org/pub/WWW/ would properly include:

   GET /pub/WWW/ HTTP/1.1
   Host: www.w3.org

我知道你的痛苦。我们的负载均衡器 运行 遇到了同样的问题。我相信 WSO2 对此有一个修复。同时,您需要在“/_system/governance/apimgt/customsequences/in”下创建自定义 "in" 序列,内容如下:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="remove_port_In"> 
  <property name="REQUEST_HOST_HEADER" value="api.empresa.net" scope="axis2"/>
</sequence>

然后您可以在发布之前通过发布者应用程序将其作为入站自定义序列与您的 API 相关联。