Not sure where to start to debug this. I want to issue a redirect for all traffic arriving with “x-forwarded-proto” == “http”. I was thinking something like this would do the trick:
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: mhite-elbgateway-http-redir
namespace: istio-system
spec:
workloadLabels:
app: mhite-elbgateway
filters:
- listenerMatch:
listenerType: GATEWAY
portNumber: 443
listenerProtocol: HTTP
filterName: envoy.lua
filterType: HTTP
insertPosition:
index: FIRST
filterConfig:
inlineCode: |
function envoy_on_request(request_handle)
-- Response directly with a redirect when X-Forwarded-Proto == "http"
local headers = request_handle:headers()
local xfp = headers:get('x-forwarded-proto')
if xfp == "http" then
local path = headers:get(':path')
local authority = headers:get(':authority')
local location = "https://" .. authority .. path
request_handle:respond({[":status"] = "308", ["Location"] = location}, "308 Permanent Redirect")
end
end
I’m running Istio 1.4.6. For what it is worth, when I use istioctl proxy-config listener, I can see it attached as a filter:
Snippet:
"filters": [
{
"name": "envoy.http_connection_manager",
"typedConfig": {
"@type": "type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager",
"statPrefix": "outbound_0.0.0.0_443",
"rds": {
"configSource": {
"ads": {}
},
"routeConfigName": "https.443.https.mhite-elbgateway.istio-system"
},
"httpFilters": [
{
"name": "envoy.lua",
"config": {
"inlineCode": "function envoy_on_request(request_handle)\n -- Response directly with a redirect when X-Forwarded-Proto == \"http\"\n local headers = request_handle:headers()\n local xfp = headers:get('x-forwarded-proto')\n if xfp == \"http\" then\n local path = headers:get(':path')\n local authority = headers:get(':authority')\n local location = \"https://\" .. authority .. path\n request_handle:respond({[\":status\"] = \"308\", [\"Location\"] = location}, \"308 Permanent Redirect\")\n end\nend\n"
}
},
{
"name": "envoy.filters.http.jwt_authn",
"typedConfig": {
"@type": "type.googleapis.com/envoy.config.filter.http.jwt_authn.v2alpha.JwtAuthentication",
"providers": {
"origins-0": {
Any ideas or pointers from folks who have gone down this path would be much appreciated!