k8s ingress CORS的解决方法
程序员文章站
2022-07-14 10:28:14
...
ingress --traefik
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: test-ingress
namespace: test
labels:
app: test-cors-app
annotations:
kubernetes.io/ingress.class: traefik
traefik.ingress.kubernetes.io/custom-response-headers: "Access-Control-Allow-Origin:*||Access-Control-Allow-Methods:GET,POST,OPTIONS||Access-Control-Allow-Headers:DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range||Access-Control-Expose-Headers:Content-Length,Content-Range"
spec:
rules:
- host: company.host
http:
paths:
- path: /
backend:
serviceName: test-service
servicePort: 80
ingress --nginx
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/cors-allow-headers: >-
DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization
nginx.ingress.kubernetes.io/cors-allow-methods: 'PUT, GET, POST, OPTIONS'
nginx.ingress.kubernetes.io/cors-allow-origin: '*'
nginx.ingress.kubernetes.io/enable-cors: 'true'
nginx.ingress.kubernetes.io/service-weight: ''
creationTimestamp: '2019-06-27T12:36:08Z'
generation: 1
name: hs-http
namespace: default
resourceVersion: '81912785'
selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/hs-http
uid: 2343101d-98d8-11e9-8792-7a7bebcd6704
spec:
rules:
- host: hs.k8s.test.com
http:
paths:
- backend:
serviceName: custom-hs
servicePort: 80
path: /
tls:
- hosts:
- hs.k8s.test.com
secretName: hs-secret0
上一篇: docker buildx 安装和使用
下一篇: Dockerfile 多段构建