Skip to content

Instantly share code, notes, and snippets.

@dio
Last active October 16, 2019 22:38
Show Gist options
  • Save dio/43c34b23fbd573a7276e766e4e5e2e16 to your computer and use it in GitHub Desktop.
Save dio/43c34b23fbd573a7276e766e4e5e2e16 to your computer and use it in GitHub Desktop.
$ yarn
$ # or npm install
$ node dump.js
$ # from another tab
$ envoy -c envoy.yaml
$ # from another tab
$ curl localhost:10000
const Server = require('http').Server;
const rawBody = require('raw-body');
const server = new Server(async (req, res) => {
console.log(req.url);
console.log(req.headers);
console.log((await rawBody(req)).toString());
res.statusCode = 503;
res.end('ok');
});
server.listen(process.env.PORT || 8000);
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address:
protocol: TCP
address: 127.0.0.1
port_value: 9901
static_resources:
listeners:
- name: listener_0
address:
socket_address:
protocol: TCP
address: 0.0.0.0
port_value: 10000
filter_chains:
- filters:
- name: envoy.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match:
prefix: "/"
route:
timeout: 10s
retry_policy:
retry_on: 5xx
num_retries: 5
per_try_timeout: 5s
retry_host_predicate:
- name: envoy.retry_host_predicates.previous_hosts
- name: envoy.retry_host_predicates.previous_hosts
host_selection_retry_max_attempts: '5'
retriable_status_codes:
- 503
max_grpc_timeout: 10s
cluster: service_google
http_filters:
- name: envoy.router
clusters:
- name: service_google
connect_timeout: 0.25s
type: LOGICAL_DNS
# Comment out the following line to test on v6 networks
dns_lookup_family: V4_ONLY
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: service_google
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: localhost
port_value: 8000
{
"name": "hello",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"raw-body": "^2.4.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment