code: private void setupForwardedHeaders(HttpAcceptSession acceptSession, HttpConnectSession connectSession) {
          if (FORWARDED_EXCLUDE.equalsIgnoreCase(useForwarded)) {
              excludeForwardedHeaders(connectSession);
              return;
          }
  
          if (FORWARDED_INJECT.equalsIgnoreCase(useForwarded)) {
              String remoteIpWithPort = format("%s:%d", getResourceIpAddress(acceptSession, FORWARDED_FOR), remoteClientPort);
              if (remoteIpWithPort != null) {
                  connectSession.addWriteHeader(HEADER_X_FORWARDED_FOR, remoteIpWithPort);
              }
  
              String serverIpAddress = getResourceIpAddress(acceptSession, FORWARDED_BY);
              if (serverIpAddress != null) {
                  connectSession.addWriteHeader(HEADER_X_FORWARDED_SERVER, serverIpAddress);
              }
  
              String protocol = acceptSession.isSecure() ? "https" : "http";
              connectSession.addWriteHeader(HEADER_X_FORWARDED_PROTO, protocol);
  
              String externalURI = acceptSession.getLocalAddress().getExternalURI();
              String host = URIUtils.getHost(externalURI);
              String port = format("%d", URIUtils.getPort(externalURI));
              connectSession.addWriteHeader(HEADER_X_FORWARDED_HOST, format("%s:%s", host, port));
              
              connectSession.addWriteHeader(HEADER_FORWARDED,
                      format("%s=%s;%s=%s;%s=%s;%s=%s:%s", FORWARDED_FOR, remoteIpWithPort, FORWARDED_BY, serverIpAddress,
                              FORWARDED_PROTO, protocol, FORWARDED_HOST, host, port));
          }
      }
docs: Compose the Forwarded header and the X-Forwarded headers and add them to the connect session write headers.
  
  @param acceptSession
  @param connectSession
  @param forwardedProperty the value of the 'use-forwarded' property used for http.proxy type in gateway-config:
  inject (add the corresponding data to the Forwarded/X-Forwarded headers), ignore (this proxy is anonymous, no
  forwarded header data is added), or exclude (delete any existing Forwarded/X-Forwarded headers received, and do
  not add any new data)