@@ -574,191 +574,34 @@ used to delimit variable names.
574
574
doubling it. For example, to emit a header with the value ``100% ``, the custom header value in
575
575
the Envoy configuration must be ``100%% ``.
576
576
577
- Supported variable names are:
577
+ All HTTP :ref: `Command Operators <config_access_log_command_operators >` used for access logging may be specified
578
+ in custom request/response headers. However, depending where a particular command operator is used, the context needed for
579
+ the operator may not be available and the produced output is empty string. For example, the following configuration
580
+ uses ``%RESPONSE_CODE% `` operator to modify request headers using code from the response.
581
+ The output is an empty string, because request headers are modified
582
+ before the request is sent upstream and the response is not received yet.
583
+
584
+ .. literalinclude :: _include/header_formatters.yaml
585
+ :language: yaml
586
+ :linenos:
587
+ :lines: 15-20
588
+ :emphasize-lines: 3-6
589
+ :caption: :download: `header_formatters.yaml <_include/header_formatters.yaml >`
578
590
579
- %DOWNSTREAM_REMOTE_ADDRESS%
580
- Remote address of the downstream connection. If the address is an IP address it includes both
581
- address and port.
582
-
583
- .. note ::
584
-
585
- This may not be the physical remote address of the peer if the address has been inferred from
586
- :ref: `Proxy Protocol filter <config_listener_filters_proxy_protocol >` or :ref: `x-forwarded-for
587
- <config_http_conn_man_headers_x-forwarded-for>`.
591
+ .. attention ::
588
592
589
- %DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%
590
- Remote address of the downstream connection, without any port component.
591
- IP addresses are the only address type with a port component.
593
+ The following legacy header formatters are still supported, but will be deprecated in the future.
594
+ The equivalent information can be accessed using indicated substitutes.
592
595
593
- .. note ::
596
+ ``%DYNAMIC_METADATA(["namespace", "key", ...])% ``
597
+ Populates the header with dynamic metadata available in a request
598
+ (e.g.: added by filters like the header-to-metadata filter).
594
599
595
- This may not be the physical remote address of the peer if the address has been inferred from
596
- :ref: `Proxy Protocol filter <config_listener_filters_proxy_protocol >` or :ref: `x-forwarded-for
597
- <config_http_conn_man_headers_x-forwarded-for>`.
600
+ This works both on request and response headers.
598
601
599
- %DOWNSTREAM_REMOTE_PORT%
600
- Remote port of the downstream connection.
601
- IP addresses are the only address type with a port component.
602
+ Use :ref: `%DYNAMIC_METADATA(namespace:key:…):Z%<config_access_log_format_dynamic_metadata> ` instead.
602
603
603
- .. note ::
604
-
605
- This may not be the physical remote address of the peer if the address has been inferred from
606
- :ref: `Proxy Protocol filter <config_listener_filters_proxy_protocol >` or :ref: `x-forwarded-for
607
- <config_http_conn_man_headers_x-forwarded-for>`.
608
-
609
- %DOWNSTREAM_DIRECT_REMOTE_ADDRESS%
610
- Direct remote address of the downstream connection. If the address is an IP address it includes both
611
- address and port.
612
-
613
- .. note ::
614
-
615
- This is always the physical remote address of the peer even if the downstream remote address has
616
- been inferred from :ref: `Proxy Protocol filter <config_listener_filters_proxy_protocol >`
617
- or :ref: `x-forwarded-for <config_http_conn_man_headers_x-forwarded-for >`.
618
-
619
- %DOWNSTREAM_DIRECT_REMOTE_ADDRESS_WITHOUT_PORT%
620
- Direct remote address of the downstream connection, without any port component.
621
- IP addresses are the only address type with a port component.
622
-
623
- .. note ::
624
-
625
- This is always the physical remote address of the peer even if the downstream remote address has
626
- been inferred from :ref: `Proxy Protocol filter <config_listener_filters_proxy_protocol >`
627
- or :ref: `x-forwarded-for <config_http_conn_man_headers_x-forwarded-for >`.
628
-
629
- %DOWNSTREAM_DIRECT_REMOTE_PORT%
630
- Direct remote port of the downstream connection.
631
- IP addresses are the only address type with a port component.
632
-
633
- .. note ::
634
-
635
- This is always the physical remote address of the peer even if the downstream remote address has
636
- been inferred from :ref: `Proxy Protocol filter <config_listener_filters_proxy_protocol >`
637
- or :ref: `x-forwarded-for <config_http_conn_man_headers_x-forwarded-for >`.
638
-
639
-
640
- %DOWNSTREAM_LOCAL_ADDRESS%
641
- Local address of the downstream connection. If the address is an IP address it includes both
642
- address and port.
643
-
644
- If the original connection was redirected by iptables REDIRECT, this represents
645
- the original destination address restored by the
646
- :ref: `Original Destination Filter <config_listener_filters_original_dst >` using SO_ORIGINAL_DST socket option.
647
- If the original connection was redirected by iptables TPROXY, and the listener's transparent
648
- option was set to true, this represents the original destination address and port.
649
-
650
- %DOWNSTREAM_LOCAL_ADDRESS_WITHOUT_PORT%
651
- Local address of the downstream connection, without any port component.
652
- IP addresses are the only address type with a port component.
653
-
654
- %DOWNSTREAM_LOCAL_PORT%
655
- Local port of the downstream connection.
656
- IP addresses are the only address type with a port component.
657
-
658
- %DOWNSTREAM_LOCAL_URI_SAN%
659
- HTTP
660
- The URIs present in the SAN of the local certificate used to establish the downstream TLS connection.
661
- TCP
662
- The URIs present in the SAN of the local certificate used to establish the downstream TLS connection.
663
-
664
- %DOWNSTREAM_PEER_URI_SAN%
665
- HTTP
666
- The URIs present in the SAN of the peer certificate used to establish the downstream TLS connection.
667
- TCP
668
- The URIs present in the SAN of the peer certificate used to establish the downstream TLS connection.
669
-
670
- %DOWNSTREAM_LOCAL_SUBJECT%
671
- HTTP
672
- The subject present in the local certificate used to establish the downstream TLS connection.
673
- TCP
674
- The subject present in the local certificate used to establish the downstream TLS connection.
675
-
676
- %DOWNSTREAM_PEER_SUBJECT%
677
- HTTP
678
- The subject present in the peer certificate used to establish the downstream TLS connection.
679
- TCP
680
- The subject present in the peer certificate used to establish the downstream TLS connection.
681
-
682
- %DOWNSTREAM_PEER_ISSUER%
683
- HTTP
684
- The issuer present in the peer certificate used to establish the downstream TLS connection.
685
- TCP
686
- The issuer present in the peer certificate used to establish the downstream TLS connection.
687
-
688
- %DOWNSTREAM_TLS_SESSION_ID%
689
- HTTP
690
- The session ID for the established downstream TLS connection.
691
- TCP
692
- The session ID for the established downstream TLS connection.
693
-
694
- %DOWNSTREAM_TLS_CIPHER%
695
- HTTP
696
- The OpenSSL name for the set of ciphers used to establish the downstream TLS connection.
697
- TCP
698
- The OpenSSL name for the set of ciphers used to establish the downstream TLS connection.
699
-
700
- %DOWNSTREAM_TLS_VERSION%
701
- HTTP
702
- The TLS version (e.g., ``TLSv1.2 ``, ``TLSv1.3 ``) used to establish the downstream TLS connection.
703
- TCP
704
- The TLS version (e.g., ``TLSv1.2 ``, ``TLSv1.3 ``) used to establish the downstream TLS connection.
705
-
706
- %DOWNSTREAM_PEER_FINGERPRINT_256%
707
- HTTP
708
- The hex-encoded SHA256 fingerprint of the client certificate used to establish the downstream TLS connection.
709
- TCP
710
- The hex-encoded SHA256 fingerprint of the client certificate used to establish the downstream TLS connection.
711
-
712
- %DOWNSTREAM_PEER_FINGERPRINT_1%
713
- HTTP
714
- The hex-encoded SHA1 fingerprint of the client certificate used to establish the downstream TLS connection.
715
- TCP
716
- The hex-encoded SHA1 fingerprint of the client certificate used to establish the downstream TLS connection.
717
-
718
- %DOWNSTREAM_PEER_SERIAL%
719
- HTTP
720
- The serial number of the client certificate used to establish the downstream TLS connection.
721
- TCP
722
- The serial number of the client certificate used to establish the downstream TLS connection.
723
-
724
- %DOWNSTREAM_PEER_CERT%
725
- HTTP
726
- The client certificate in the URL-encoded PEM format used to establish the downstream TLS connection.
727
- TCP
728
- The client certificate in the URL-encoded PEM format used to establish the downstream TLS connection.
729
-
730
- %DOWNSTREAM_PEER_CERT_V_START%
731
- HTTP
732
- The validity start date of the client certificate used to establish the downstream TLS connection.
733
- TCP
734
- The validity start date of the client certificate used to establish the downstream TLS connection.
735
-
736
- DOWNSTREAM_PEER_CERT_V_START can be customized with specifiers as specified in
737
- :ref: `access log format rules<config_access_log_format_downstream_peer_cert_v_start> `.
738
-
739
- %DOWNSTREAM_PEER_CERT_V_END%
740
- HTTP
741
- The validity end date of the client certificate used to establish the downstream TLS connection.
742
- TCP
743
- The validity end date of the client certificate used to establish the downstream TLS connection.
744
-
745
- DOWNSTREAM_PEER_CERT_V_END can be customized with specifiers as specified in
746
- :ref: `access log format rules<config_access_log_format_downstream_peer_cert_v_end> `.
747
-
748
- %HOSTNAME%
749
- The system hostname.
750
-
751
- %PROTOCOL%
752
- The original protocol which is already added by Envoy as a
753
- :ref: `x-forwarded-proto <config_http_conn_man_headers_x-forwarded-proto >` request header.
754
-
755
- %REQUESTED_SERVER_NAME%
756
- HTTP
757
- String value set on ssl connection socket for Server Name Indication (SNI)
758
- TCP
759
- String value set on ssl connection socket for Server Name Indication (SNI)
760
-
761
- %UPSTREAM_METADATA(["namespace", "key", ...])%
604
+ ``%UPSTREAM_METADATA(["namespace", "key", ...])% ``
762
605
Populates the header with :ref: `EDS endpoint metadata <envoy_v3_api_field_config.endpoint.v3.LbEndpoint.metadata >` from the
763
606
upstream host selected by the router. Metadata may be selected from any namespace. In general,
764
607
metadata values may be strings, numbers, booleans, lists, nested structures, or null. Upstream
@@ -771,74 +614,12 @@ Supported variable names are:
771
614
Upstream metadata cannot be added to request headers as the upstream host has not been selected
772
615
when custom request headers are generated.
773
616
774
- %DYNAMIC_METADATA(["namespace", "key", ...])%
775
- Similar to UPSTREAM_METADATA, populates the header with dynamic metadata available in a request
776
- (e.g.: added by filters like the header-to-metadata filter).
777
-
778
- This works both on request and response headers.
779
-
780
- %UPSTREAM_LOCAL_ADDRESS%
781
- Local address of the upstream connection. If the address is an IP address it includes both
782
- address and port.
783
-
784
- The upstream local address cannot be added to request headers as the upstream host
785
- hremote as not been selected when custom request headers are generated.
786
-
787
- %UPSTREAM_LOCAL_ADDRESS_WITHOUT_PORT%
788
- Local address of the upstream connection, without any port component.
789
- IP addresses are the only address type with a port component.
790
-
791
- %UPSTREAM_LOCAL_PORT%
792
- Local port of the upstream connection.
793
- IP addresses are the only address type with a port component.
617
+ Use :ref: `%UPSTREAM_METADATA(namespace:key:…):Z%<config_access_log_format_upstream_host_metadata> ` instead.
794
618
795
- %UPSTREAM_REMOTE_ADDRESS%
796
- Remote address of the upstream connection. If the address is an IP address it includes both
797
- address and port.
798
-
799
- The upstream remote address cannot be added to request headers as the upstream host
800
- has not been selected when custom request headers are generated.
801
-
802
- %UPSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%
803
- Remote address of the upstream connection, without any port component.
804
- IP addresses are the only address type with a port component.
805
-
806
- %UPSTREAM_REMOTE_PORT%
807
- Remote port of the upstream connection.
808
- IP addresses are the only address type with a port component.
809
-
810
- %PER_REQUEST_STATE(reverse.dns.data.name)%
811
- Populates the header with values set on the stream info filterState() object. To be
619
+ ``%PER_REQUEST_STATE(reverse.dns.data.name)% ``
620
+ Populates the header with values set on the stream info ``filterState() `` object. To be
812
621
usable in custom request/response headers, these values must be of type
813
- Envoy::Router: :StringAccessor. These values should be named in standard reverse DNS style,
622
+ `` Envoy::Router::StringAccessor `` . These values should be named in standard reverse DNS style,
814
623
identifying the organization that created the value and ending in a unique name for the data.
815
624
816
- %REQ(header-name)%
817
- Populates the header with a value of the request header.
818
-
819
- %START_TIME%
820
- Request start time. START_TIME can be customized with specifiers as specified in
821
- :ref: `access log format rules<config_access_log_format_start_time> `.
822
-
823
- An example of setting a custom header with current time in seconds with the milliseconds resolution:
824
-
825
- .. code-block :: none
826
-
827
- route:
828
- cluster: www
829
- request_headers_to_add:
830
- - header:
831
- key: "x-request-start"
832
- value: "%START_TIME(%s.%3f)%"
833
- append_action: APPEND_IF_EXISTS_OR_ADD
834
-
835
- %RESPONSE_FLAGS%
836
- Additional details about the response or connection, if any. Possible values and their meanings
837
- are listed in the access log formatter :ref: `documentation<config_access_log_format_response_flags> `.
838
-
839
- %RESPONSE_CODE_DETAILS%
840
- Response code details provides additional information about the HTTP response code, such as
841
- who set it (the upstream or envoy) and why.
842
-
843
- %VIRTUAL_CLUSTER_NAME%
844
- Name of the Virtual Cluster which gets matched (if any).
625
+ Use :ref: `%FILTER_STATE(reverse.dns.data.name:PLAIN):Z%<config_access_log_format_filter_state> ` instead.
0 commit comments