-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenvoy.yml
154 lines (144 loc) · 6.02 KB
/
envoy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 8000
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: AUTO
stat_prefix: ingress_http
local_reply_config:
mappers:
- filter:
status_code_filter:
comparison:
op: EQ
value:
default_value: 404
runtime_key: none
body:
filename: /etc/404.html
body_format_override:
text_format_source:
inline_string: "%LOCAL_REPLY_BODY%"
content_type: "text/html; charset=UTF-8"
access_log:
- name: envoy.access_loggers.stdout
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
route_config:
name: routes
virtual_hosts:
- name: apps
domains:
- "*"
routes:
- match:
prefix: "/service/1"
route:
cluster: service1
prefix_rewrite: "/"
- match:
prefix: "/service/2"
route:
cluster: service2
prefix_rewrite: "/"
http_filters:
#
# decompressors
#
- name: gzip decompressor
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.decompressor.v3.Decompressor
decompressor_library:
name: basic
typed_config:
"@type": type.googleapis.com/envoy.extensions.compression.gzip.decompressor.v3.Gzip
- name: brotli decompressor
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.decompressor.v3.Decompressor
decompressor_library:
name: basic
typed_config:
"@type": type.googleapis.com/envoy.extensions.compression.brotli.decompressor.v3.Brotli
#
# lua
#
- name: envoy.filters.http.lua
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
default_source_code:
inline_string: |
math.randomseed(os.time())
function envoy_on_request(request_handle)
end
function envoy_on_response(response_handle)
-- this lua should rewrite the html
response_handle:logDebug("entered envoy_on_response")
local content_type = response_handle:headers():get("content-type")
response_handle:logDebug("content type = ")
response_handle:logDebug(content_type)
if string.find(content_type, "text/html") then
response_handle:logDebug("this is text/html")
response_handle:logDebug("getting html")
local html = response_handle:body():getBytes(0, response_handle:body():length())
response_handle:logDebug("html = ")
response_handle:logDebug(html)
-- replace some content
local rewritten1 = string.gsub(html, "<p>replace</p>", "<p>envoy replaced this content</p>")
local rewritten2 = string.gsub(rewritten1, "jack", "<b>" .. os.date("!%c") .. "</b>")
response_handle:logDebug("new html =")
response_handle:logDebug(rewritten2)
response_handle:body():setBytes(rewritten2)
end
response_handle:logDebug("all done")
end
#
# router
#
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
clusters:
- name: service1
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: service1
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: service1
port_value: 8011
- name: service2
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: service2
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: service2
port_value: 8012
admin:
address:
socket_address:
address: 0.0.0.0
port_value: 8001
layered_runtime:
layers:
- name: static_layer_0
static_layer:
envoy:
resource_limits:
listener:
example_listener_name:
connection_limit: 10000