envoyproxy / envoyproxy/nighthawk

Wasm filter with test server

Open
#739 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
414
Forks
95
Avg merge
2d 9h
Merged PRs (30d)
11

Description

I am trying to add a wasm http filter to the filter chain. I have used the config.yaml shown in a some examples, and added the wasm filter given in envoy wasm-cc example as shown below -

```
static_resources:
listeners:
# define an origin server on :10000 that always returns "lorem ipsum..."
- address:
socket_address:
address: 0.0.0.0
port_value: 10000
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
generate_request_id: false
codec_type: AUTO
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: service
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: web_service
http_filters:
- name: test-server # before envoy.router because order matters!
typed_config:
"@type": type.googleapis.com/nighthawk.server.ResponseOptions
response_body_size: 10
v3_response_headers:
- { header: { key: "foo", value: "bar" } }
- {
header: { key: "foo", value: "bar2" },
append: true,
}
- { header: { key: "x-nh", value: "1" } }
- name: envoy.filters.http.wasm
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm
config:
name: "my_plugin"
root_id: "my_root_id"
# if your wasm filter requires custom configuration you can add
# as follows
# configuration:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
{}
vm_config:
runtime: "envoy.wasm.runtime.wasmtime"
vm_id: "my_vm_id"
code:
local:
filename: "/home/xyz/envoyrepo/envoy/examples/wasm-cc/lib/envoy_filter_http_wasm_example.wasm"
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
dynamic_stats: false

clusters:
- name: web_service
type: strict_dns
lb_policy: round_robin
load_assignment:
cluster_name: service1
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: web_service
port_value: 9000

```

I have built nighthawk_test_server with wasmtime enabled by adding the extension to `extensions_build_config.bzl` as well as building it with `--define wasm=wasmtime`, and the test_server starts as expected.
However, I don't see the expected header/body additions from the wasm filter in the response with a curl request, just those from the test-server filters.
```
$ curl -v localhost:10000
* Uses proxy env variable no_proxy == 'localhost'
* Trying 127.0.0.1:10000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 10000 (#0)
> GET / HTTP/1.1
> Host: localhost:10000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< foo: bar
< foo: bar2
< x-nh: 1
< content-length: 10
< content-type: text/plain
< date: Mon, 30 Aug 2021 17:58:36 GMT
< server: envoy
<
* Connection #0 to host localhost left intact
aaaaaaaaaa
```

Am I configuring the wasm filter incorrectly?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.