Start the OPA server with the rules in example.rego:
./kiper opa run --server --set=plugins.envoy_ext_authz_grpc.addr=:9191 --set=plugins.envoy_ext_authz_grpc.query=data.envoy.authz.allow --set=decision_logs.console=true --ignore=.* example.rego
Start Envoy with the given config file that authorizes using the server above:
envoy -c envoy_config.yaml
The example.rego policy defines a limit of 5 requests per second for the
"/abc" path, but each user identified by the "user_id" header can only make 3
requests per second. To test this, you'll need to start a server in 8080 or choose another one, but remember to change it in envoy_config.yaml as well. For testing purposes you can use: python -m http.server 8080. Now make requests to Envoy:
By default, the limits are stored in memory. You can use Redis if you need to
share the limits between several instances or need to persist them. Simply set
the REDIS_URL env. It accepts a URL with this format: redis://host:port/db
(db is optional).