tencent cloud

Feedback

Method 2: Parsing Real Client IPs on Application Server

Last updated: 2023-09-11 17:43:51

    Scenarios

    Scenario 1: If the UDP protocol is used on the origin, only Proxy Protocol V2 can be selected to pass the real client IPs. In this case, you need to parse the Proxy Protocol V2 on the application server to obtain the real client IPs.
    Scenario 2: If the TCP protocol is used on the origin, and you want to implement application judgment via the real client IPs on the application server, you need to parse the Proxy Protocol V1/V2 on the application server to obtain the real client IPs.

    Deployment Diagram

    
    
    
    As shown in the above diagram, you can configure L4 proxy via EdgeOne L4 proxy module to point to the application server, and add the Proxy Protocol field to the application data by EdgeOne L4 proxy service. Parsing is implemented on the application server.

    Directions

    Step 1: Configure L4 proxy forwarding rule

    Modify the L4 proxy forwarding rule in the console. You need to enter the origin address and origin port. If the forwarding protocol is UDP, select Proxy Protocol V2 for Pass client IP. If the forwarding protocol is TCP, you can select Proxy Protocol V1 or V2. For details, see Modifying L4 Proxy Forwarding Rules.
    
    
    

    Step 2: Obtain real client IPs on the application server

    You need to parse the Proxy Protocol filed with reference to the sample code in the Proxy Protocol. For the format of the client IPs, see Format of Real Client IPs Obtained Through Proxy Protocol V1/V2.
    
    When the UDP protocol and Proxy Protocol V2 are selected, the Proxy Protocol field is added to the first UDP datagram. In the figure below, ① refers to the L4 proxy egress IP, ② refers to the origin address, ③ refers to the protocol version, ④ refers to the Proxy Protocol field, ⑤ refers to the real client IP address, and ⑥ refers to the application data.
    
    
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support