Unable to get the corsPolicy to work.
below is my configs
am i doing something wrong ?
Istio Version:“1.1.7”
curl 35.xx.xx.xx.nip.io/hello -v
* Trying 35.xx.xx.xx...
* TCP_NODELAY set
* Connected to 35.xx.xx.xx.nip.io (35.xx.xx.xx) port 80 (#0)
> GET /hello HTTP/1.1
> Host: 35.xx.xx.xx.nip.io
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< content-type: text/html; charset=utf-8
< content-length: 59
< date: Thu, 13 Jun 2019 07:16:47 GMT
< server: istio-envoy
<
Hello version: v2, instance: helloworld-v2-6489d9fb5-qcm5j
* Connection #0 to host 35.xx.xx.xx.nip.io left intact
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
generation: 1
name: helloworld-gateway
namespace: temp
resourceVersion: "48893351"
spec:
selector:
istio: ingressgateway
servers:
- hosts:
- 35.xx.xx.xx.nip.io
port:
name: http-helloworld
number: 80
protocol: HTTP
- hosts:
- 35.xx.xx.xx.nip.io
port:
name: https-helloworld
number: 443
protocol: HTTPS
tls:
credentialName: httpbin-credential2
mode: MUTUAL
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
generation: 1
name: helloworld
namespace: temp
spec:
gateways:
- helloworld-gateway
hosts:
- 35.xx.xx.xx.nip.io
http:
- corsPolicy:
allowCredentials: true
allowHeaders:
- authorization
- content-type
- accept
- origin
- user-agent
allowMethods:
- POST
allowOrigin:
- foo.example
exposeHeaders:
- x-custom-header
maxAge: 300s
match:
- uri:
exact: /hello
removeResponseHeaders:
- server
- x-envoy-upstream-service-time
output from istioctl
{
"name": "http.80",
"virtualHosts": [
{
"name": "35.xx.xx.xx.nip.io:80",
"domains": [
"35.xx.xx.xx.nip.io",
"35.xx.xx.xx.nip.io:80"
],
"routes": [
{
"match": {
"path": "/hello"
},
"route": {
"cluster": "outbound|5000||helloworld.temp.svc.cluster.local",
"timeout": "0s",
"retryPolicy": {
"retryOn": "connect-failure,refused-stream,unavailable,cancelled,resource-exhausted,retriable-status-codes",
"numRetries": 2,
"retryHostPredicate": [
{
"name": "envoy.retry_host_predicates.previous_hosts"
}
],
"hostSelectionRetryMaxAttempts": "3",
"retriableStatusCodes": [
503
]
},
"cors": {
"allowOrigin": [
"foo.example"
],
"allowMethods": "POST",
"allowHeaders": "authorization,content-type,accept,origin,user-agent",
"exposeHeaders": "x-custom-header",
"maxAge": "300",
"allowCredentials": true,
"filterEnabled": {
"defaultValue": {
"numerator": 100
}
}
},
"maxGrpcTimeout": "0s"
},
"metadata": {
"filterMetadata": {
"istio": {
"config": "/apis/networking/v1alpha3/namespaces/temp/virtual-service/helloworld"
}
}
},
"decorator": {
"operation": "helloworld.temp.svc.cluster.local:5000/hello"
},
"perFilterConfig": {
"mixer": {
"forward_attributes": {
"attributes": {
"destination.service.host": {
"string_value": "helloworld.temp.svc.cluster.local"
},
"destination.service.name": {
"string_value": "helloworld"
},
"destination.service.namespace": {
"string_value": "temp"
},
"destination.service.uid": {
"string_value": "istio://temp/services/helloworld"
}
}
},
"mixer_attributes": {
"attributes": {
"destination.service.host": {
"string_value": "helloworld.temp.svc.cluster.local"
},
"destination.service.name": {
"string_value": "helloworld"
},
"destination.service.namespace": {
"string_value": "temp"
},
"destination.service.uid": {
"string_value": "istio://temp/services/helloworld"
}
}
}
}
},
"responseHeadersToRemove": [
"server",
"x-envoy-upstream-service-time"
]
}
]
}
],
"validateClusters": false
},