tet*_*241 6 kubernetes kubernetes-ingress
我想阻止/public/configs我的 k8s 入口。
我当前的设置不起作用。
- host: example.com
http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: service-myapp
port:
number: 80
- path: /public/configs
pathType: ImplementationSpecific
backend:
service:
name: service-myapp
port:
number: 88 // fake port
Run Code Online (Sandbox Code Playgroud)
有没有更好(简单)的方法?
小智 6
1- 创建一个虚拟服务并将其发送到该服务:
- path: /public/configs
pathType: ImplementationSpecific
backend:
service:
name: dummy-service
port:
number: 80
Run Code Online (Sandbox Code Playgroud)
2-使用server-snippets如下命令返回 403 或任何您想要的错误:
a) 对于 k8s nginx 入口:
annotations:
nginx.ingress.kubernetes.io/server-snippet: |
location ~* "^/public/configs" {
deny all;
return 403;
}
Run Code Online (Sandbox Code Playgroud)
b) 对于 nginx 入口:
annotations:
nginx.org/server-snippet: |
location ~* "^/public/configs" {
deny all;
return 403;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2225 次 |
| 最近记录: |