Skip to content

Instantly share code, notes, and snippets.

@pubudu538
Created June 24, 2024 13:03
Show Gist options
  • Select an option

  • Save pubudu538/76db90abc0df8d81dbe239e740428609 to your computer and use it in GitHub Desktop.

Select an option

Save pubudu538/76db90abc0df8d81dbe239e740428609 to your computer and use it in GitHub Desktop.
Route Config - Envoy
{
"name": "default",
"virtual_hosts": [
{
"name": "localhost",
"domains": [
"localhost",
"localhost:*"
],
"routes": [
{
"match": {
"headers": [
{
"name": ":method",
"safe_regex_match": {
"google_re2": {},
"regex": "^(GET|OPTIONS)$"
}
}
],
"safe_regex": {
"google_re2": {},
"regex": "^/mock/v1/mockresource(\\?([^/]+))?$"
}
},
"route": {
"cluster_header": "x-wso2-cluster-header",
"auto_host_rewrite": true,
"timeout": "60s",
"cors": {
"allow_methods": "GET, PUT, POST, DELETE, PATCH, OPTIONS",
"allow_headers": "authorization, Access-Control-Allow-Origin, Content-Type, SOAPAction, apikey, testKey, Internal-Key",
"allow_credentials": false,
"allow_origin_string_match": [
{
"safe_regex": {
"google_re2": {},
"regex": "\\*"
}
}
]
},
"idle_timeout": "300s",
"upgrade_configs": [
{
"upgrade_type": "websocket",
"enabled": false
}
],
"regex_rewrite": {
"pattern": {
"google_re2": {},
"regex": "/mock/v1\\?n)"
},
"substitution": "/v2/5185415ba171ea3a00704eed"
}
},
"decorator": {
"operation": "/mockresource"
},
"response_headers_to_remove": [
"x-envoy-upstream-service-time"
],
"typed_per_filter_config": {
"envoy.filters.http.ext_authz": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute",
"check_settings": {
"context_extensions": {
"basePath": "/mock/v1",
"method": "GET",
"name": "mockAPI",
"path": "/mockresource",
"prodClusterName": "carbon.super_clusterProd_localhost_mockAPIv1",
"sandClusterName": "carbon.super_clusterSand_localhost_mockAPIv1",
"vHost": "localhost",
"version": "v1"
}
}
},
"envoy.filters.http.lua": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.LuaPerRoute",
"disabled": true
}
},
"name": "/mock/v1"
},
{
"match": {
"headers": [
{
"name": ":method",
"safe_regex_match": {
"google_re2": {},
"regex": "^(POST|OPTIONS)$"
}
}
],
"safe_regex": {
"google_re2": {},
"regex": "^/mock/v1/test(\\?([^/]+))?$"
}
},
"route": {
"cluster_header": "x-wso2-cluster-header",
"auto_host_rewrite": true,
"timeout": "60s",
"cors": {
"allow_methods": "GET, PUT, POST, DELETE, PATCH, OPTIONS",
"allow_headers": "authorization, Access-Control-Allow-Origin, Content-Type, SOAPAction, apikey, testKey, Internal-Key",
"allow_credentials": false,
"allow_origin_string_match": [
{
"safe_regex": {
"google_re2": {},
"regex": "\\*"
}
}
]
},
"idle_timeout": "300s",
"upgrade_configs": [
{
"upgrade_type": "websocket",
"enabled": false
}
],
"regex_rewrite": {
"pattern": {
"google_re2": {},
"regex": "/mock/v1"
},
"substitution": "/v2/5185415ba171ea3a00704eed"
}
},
"decorator": {
"operation": "/test"
},
"response_headers_to_remove": [
"x-envoy-upstream-service-time"
],
"typed_per_filter_config": {
"envoy.filters.http.lua": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.LuaPerRoute",
"disabled": true
},
"envoy.filters.http.ext_authz": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute",
"check_settings": {
"context_extensions": {
"basePath": "/mock/v1",
"method": "POST",
"name": "mockAPI",
"path": "/test",
"prodClusterName": "carbon.super_clusterProd_localhost_mockAPIv1",
"sandClusterName": "carbon.super_clusterSand_localhost_mockAPIv1",
"vHost": "localhost",
"version": "v1"
}
}
}
},
"name": "/mock/v1"
},
{
"match": {
"headers": [
{
"name": ":method",
"safe_regex_match": {
"google_re2": {},
"regex": "^(POST|PUT|DELETE|GET|PATCH|OPTIONS)$"
}
}
],
"safe_regex": {
"google_re2": {},
"regex": "^/mock/v1((/(.*))*)(\\?([^/]+))?$"
}
},
"route": {
"cluster_header": "x-wso2-cluster-header",
"auto_host_rewrite": true,
"timeout": "60s",
"cors": {
"allow_methods": "GET, PUT, POST, DELETE, PATCH, OPTIONS",
"allow_headers": "authorization, Access-Control-Allow-Origin, Content-Type, SOAPAction, apikey, testKey, Internal-Key",
"allow_credentials": false,
"allow_origin_string_match": [
{
"safe_regex": {
"google_re2": {},
"regex": "\\*"
}
}
]
},
"idle_timeout": "300s",
"upgrade_configs": [
{
"upgrade_type": "websocket",
"enabled": false
}
],
"regex_rewrite": {
"pattern": {
"google_re2": {},
"regex": "/mock/v1"
},
"substitution": "/v2/5185415ba171ea3a00704eed"
}
},
"decorator": {
"operation": "/*"
},
"response_headers_to_remove": [
"x-envoy-upstream-service-time"
],
"typed_per_filter_config": {
"envoy.filters.http.ext_authz": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute",
"check_settings": {
"context_extensions": {
"basePath": "/mock/v1",
"method": "POST PUT DELETE GET PATCH",
"name": "mockAPI",
"path": "/*",
"prodClusterName": "carbon.super_clusterProd_localhost_mockAPIv1",
"sandClusterName": "carbon.super_clusterSand_localhost_mockAPIv1",
"vHost": "localhost",
"version": "v1"
}
}
},
"envoy.filters.http.lua": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.LuaPerRoute",
"disabled": true
}
},
"name": "/mock/v1"
},
{
"match": {
"path": "/testkey"
},
"route": {
"cluster": "token_cluster",
"auto_host_rewrite": true,
"regex_rewrite": {
"pattern": {
"google_re2": {},
"regex": "/testkey"
},
"substitution": "/"
}
},
"decorator": {
"operation": "/testkey"
},
"typed_per_filter_config": {
"envoy.filters.http.ext_authz": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute",
"disabled": true
}
},
"name": "/testkey"
},
{
"match": {
"path": "/health"
},
"decorator": {
"operation": "/health"
},
"direct_response": {
"status": 200,
"body": {
"inline_string": "{\"status\": \"healthy\"}"
}
},
"typed_per_filter_config": {
"envoy.filters.http.ext_authz": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute",
"disabled": true
}
},
"name": "/health"
},
{
"match": {
"path": "/ready"
},
"decorator": {
"operation": "/ready"
},
"direct_response": {
"status": 200,
"body": {
"inline_string": "{\"status\": \"ready\"}"
}
},
"typed_per_filter_config": {
"envoy.filters.http.ext_authz": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute",
"disabled": true
}
},
"name": "/ready"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment