Unable to get corsPolicy working in istio

Viewed 2389

I am trying to get the CorsPolicy working on istio 1.1.7, but istio ignore anything related to corspolicy, RemoveResponseHeaders works. But only access-control-allow-origin and access-control-allow-credentials shows up nothing else.

Its a fresh installation on Docker for Desktop. (i reset everything just to be sure), With default installation profile.


āžœ  istio-1.1.7 curl abcd.127.0.0.1.nip.io/anything -I
HTTP/1.1 200 OK
server: istio-envoy
date: Thu, 13 Jun 2019 10:08:10 GMT
content-type: application/json
content-length: 977
access-control-allow-origin: *
access-control-allow-credentials: true

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: httpbin-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - abcd.127.0.0.1.nip.io
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: httpbin
  labels:
    app: httpbin
spec:
  hosts:
  - abcd.127.0.0.1.nip.io
  gateways:
  - httpbin-gateway
  http:
  - match:
    route:
    - destination:
        host: httpbin
        port:
          number: 8000
    corsPolicy:
      allowOrigin:
      - 'abcd.com'
      allowCredentials: false
      allowMethods: 
      - POST
      allowHeaders:
      - X-Foo-Bar
      maxAge: "24h"
    removeResponseHeaders:
    - x-envoy-upstream-service-time


---
apiVersion: v1
kind: Service
metadata:
  name: httpbin
  labels:
    app: httpbin
spec:
  ports:
  - name: http
    port: 8000
    targetPort: 80
  selector:
    app: httpbin
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: httpbin
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: httpbin
        version: v1
    spec:
      containers:
      - image: docker.io/kennethreitz/httpbin
        imagePullPolicy: IfNotPresent
        name: httpbin
        ports:
        - containerPort: 80
0 Answers
Related