Configuration.acceptProxyProtocol()
Description
Appends an acceptProxyProtocol filter to the current pipeline layout.
An acceptProxyProtocol filter implements the Proxy Protocol on the server side.
- INPUT - Data stream received from the client with a Proxy Protocol header.
- OUTPUT - Data stream to send back to the client.
- SUB-INPUT - Data stream received from the client with the Proxy Protocol header removed.
- SUB-OUTPUT - Data stream to send back to the client.
An acceptProxyProtocol filter extracts the Proxy Protocol header from the input Data stream and calls back a user handler with it. When the user handler returns true, a sub-pipeline will be created to accept the input stream without the Proxy Protocol header. The filter output is the same output from the sub-pipeline.
Syntax
pipy().pipeline().acceptProxyProtocol(header => shouldAccept(header)).to(subPipelineLayout)
Parameters
acceptProxyProtocol(handler)
handler
A function that receives the Proxy Protocol header and returns a boolean determining whether the connection should be accepted. The received header includes the following fields:
- version - Could be 1 or 2
- command - Could be "PROXY" or "LOCAL" for version 2 only
- protocol - One of "TCP4", "TCP6", "UDP4", "UDP6", "UNIX", "UNIX_DGRAM" and "UNKNOWN"
- sourceAddress - Source IP address
- sourcePort - Source port
- targetAddress - Destination IP address
- targetPort - Destination port
Return Value
The same Configuration object.