Skip to content

Instantly share code, notes, and snippets.

@moderation
Created April 13, 2021 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moderation/7878a0a4e56965a3548547795123eb85 to your computer and use it in GitHub Desktop.
Save moderation/7878a0a4e56965a3548547795123eb85 to your computer and use it in GitHub Desktop.
envoy_h3_downstream_local_direct_response_h2_upstream
admin:
access_log:
- name: envoy.access_loggers.file
typed_config:
'@type': type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /tmp/admin_access.log
address:
socket_address:
address: ::0
ipv4_compat: true
port_value: 9901
protocol: TCP
layered_runtime:
layers:
- name: static-layer
static_layer:
envoy.http.headermap.lazy_map_min_size: 3
envoy.reloadable_features.new_tcp_connection_pool: true
envoy.reloadable_features.prefer_quic_kernel_bpf_packet_routing: true
envoy.reloadable_features.remove_legacy_json: true
static_resources:
clusters:
- name: service_httpbin
connect_timeout: 2s
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: service_httpbin
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: httpbin.org
port_value: 443
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
'@type': type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
common_tls_context:
alpn_protocols: h2
sni: httpbin.org
type: LOGICAL_DNS
typed_extension_protocol_options:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicit_http_config:
http2_protocol_options: {}
listeners:
- name: listener_udp
address:
socket_address:
address: ::0
ipv4_compat: true
port_value: 4433
protocol: UDP
filter_chains:
- filter_chain_match:
transport_protocol: quic
transport_socket:
name: envoy.transport_sockets.quic
typed_config:
'@type': type.googleapis.com/envoy.extensions.transport_sockets.quic.v3.QuicDownstreamTransport
downstream_tls_context:
common_tls_context:
alpn_protocols: h3
tls_certificates:
certificate_chain:
filename: cert.pem
private_key:
filename: cert-key.pem
filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
'@type': type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
access_log:
- name: envoy.access_loggers.file
typed_config:
'@type': type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
log_format:
json_format:
bytes_received: '%BYTES_RECEIVED%'
bytes_sent: '%BYTES_SENT%'
duration: '%DURATION%'
http_response: '%RESPONSE_CODE%'
protocol: '%PROTOCOL%'
request_authority: '%REQ(:AUTHORITY)%'
request_method: '%REQ(:METHOD)%'
request_path: '%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%'
response_flag: '%RESPONSE_FLAGS%'
start_time: '%START_TIME%'
upstream_host: '%UPSTREAM_HOST%'
upstream_service_time: '%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%'
user_agent: '%REQ(USER-AGENT)%'
x_forwarded_for: '%REQ(X-FORWARDED-FOR)%'
x_request_id: '%REQ(X-REQUEST-ID)%'
path: http3_downstream.log
codec_type: HTTP3
http_filters:
- name: envoy.filters.http.router
route_config:
name: local_route
max_direct_response_body_size_bytes: 428
virtual_hosts:
- name: local_service
domains:
- '*'
routes:
- match:
prefix: /local
direct_response:
body:
inline_string: |-
<!DOCTYPE html>
<head><meta charset=utf-8><title>envoy_http3_downstream</title><link rel=icon href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSI1MDAiIGhlaWdodD0iNTAwIiBzdHlsZT0iZmlsbDojZmYwMGZmO3N0cm9rZTojZmYwMGZmOyIgLz4KPC9zdmc+IA==" type=image/svg+xml sizes=any><style> body { font-size: 70px; }</style></head><body>direct_response: You found it!</body>
status: 200
response_headers_to_add:
- header:
key: content-type
value: text/html;charset=utf-8
- match:
prefix: /
route:
cluster: service_httpbin
host_rewrite_literal: httpbin.org
stat_prefix: ingress_h3
reuse_port: true
udp_listener_config:
downstream_socket_config:
prefer_gro: true
quic_options: {}
- name: listener_tcp
address:
socket_address:
address: ::0
ipv4_compat: true
port_value: 4433
protocol: TCP
filter_chains:
- transport_socket:
name: envoy.transport_sockets.tls
typed_config:
'@type': type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
common_tls_context:
tls_certificates:
certificate_chain:
filename: cert.pem
private_key:
filename: cert-key.pem
alpn_protocols: h2
filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
'@type': type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
access_log:
- name: envoy.access_loggers.file
typed_config:
'@type': type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: http3_downstream.log
http_filters:
- name: envoy.filters.http.router
route_config:
name: local_route
max_direct_response_body_size_bytes: 428
virtual_hosts:
- domains:
- '*'
name: local_service
response_headers_to_add:
- header:
key: alt-svc
value: h3=":4433"; ma=86400, h3-29=":4433"; ma=86400
routes:
- match:
prefix: /local
direct_response:
body:
inline_string: |-
<!DOCTYPE html>
<head><meta charset=utf-8><title>envoy_http3_downstream</title><link rel=icon href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSI1MDAiIGhlaWdodD0iNTAwIiBzdHlsZT0iZmlsbDojZmYwMGZmO3N0cm9rZTojZmYwMGZmOyIgLz4KPC9zdmc+IA==" type=image/svg+xml sizes=any><style> body { font-size: 70px; }</style></head><body>direct_response: You found it!</body>
status: 200
response_headers_to_add:
- header:
key: content-type
value: text/html;charset=utf-8
- match:
prefix: /
route:
cluster: service_httpbin
host_rewrite_literal: httpbin.org
stat_prefix: ingress_h2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment