K8S ingress中添加X-Frame-Options SAMEORIGIN
时间: 2023-12-22 07:28:59 浏览: 438
x-frame-options
以下是在K8S ingress中添加X-Frame-Options SAMEORIGIN的配置示例:
```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
annotations:
nginx.ingress.kubernetes.io/configuration-snippet: |
more_set_headers "X-Frame-Options: SAMEORIGIN";
spec:
rules:
- host: www.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: exampleService
port:
number: 80
```
这个配置示例中,我们在Ingress资源的annotations中添加了nginx.ingress.kubernetes.io/configuration-snippet注释,并使用more_set_headers指令来添加X-Frame-Options: SAMEORIGIN响应标头。
阅读全文