Skip to content

Instantly share code, notes, and snippets.

@turesheim
Created October 31, 2019 19:01
Show Gist options
  • Save turesheim/74f06eed3f7b7e4df24dd44ac24038cb to your computer and use it in GitHub Desktop.
Save turesheim/74f06eed3f7b7e4df24dd44ac24038cb to your computer and use it in GitHub Desktop.
Envoy configuration for handling gRPC and HTTP requests to the same port
# =============================================================================
# This Envoy configuration allows gRPC and HTTP/2 connections to be sent to the
# same port. The URL to the gRPC service must be prefixed with "/grpc", for
# instance "http://192.168.1.10/grpc" and will be directed to port 8082. The
# normal HTTP/2 calls will be directed to port 8084.
# =============================================================================
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address: { address: 0.0.0.0, port_value: 8086 }
static_resources:
listeners:
- name: listener
address:
socket_address: { address: 0.0.0.0, port_value: 8085 }
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match: { prefix: "/grpc/" }
route:
cluster: sima_runtime_grpc
prefix_rewrite: "/"
max_grpc_timeout: 0s
- match: { prefix: "/" }
route:
cluster: sima_runtime_http
cors:
allow_origin:
- "*"
allow_methods: GET, PUT, DELETE, POST, OPTIONS
allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout,jwt
max_age: "1728000"
expose_headers: grpc-status,grpc-message,jwt
http_filters:
- name: envoy.grpc_web
- name: envoy.cors
- name: envoy.router
clusters:
- name: sima_runtime_grpc
connect_timeout: 0.25s
type: logical_dns
http2_protocol_options: {}
lb_policy: round_robin
# win/mac hosts: Use address: host.docker.internal
# instead of address: localhost in the line below
hosts: [{ socket_address: { address: 127.0.0.1, port_value: 8082 }}]
- name: sima_runtime_http
connect_timeout: 0.25s
type: logical_dns
lb_policy: round_robin
# win/mac hosts: Use address: host.docker.internal
# instead of address: localhost in the line below
hosts: [{ socket_address: { address: 127.0.0.1, port_value: 8084 }}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment