[英]routing wildcard domain to different paths in nginx ingress
我如何實現與此類似的東西。
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
ingress.kubernetes.io/rewrite-target: /c/{word-maching-wildcard}
name: some-route
namespace: prod
spec:
rules:
- host: "*.example.com" # {hello}.example.com -> hello.example.com/hello
http:
paths:
- backend:
serviceName: svc
servicePort: 8080
path: /
在路由到上游服務之前,有什么方法可以捕獲子域中的匹配詞和路徑中的 append。
來自官方文檔:
spec.rules.host
字段不支持正則表達式和通配符。 必須使用完整的主機名。
請參閱: nginx-ingress-matching 。
但是我發現了類似的問題,建議編寫您自己的 controller 寫出一個 nginx 配置,該配置在適當的proxy_pass
或重定向行中使用$http_host
。
閱讀更多: 通配符 url 映射。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.