简体   繁体   English

将通配符域路由到 nginx 入口中的不同路径

[英]routing wildcard domain to different paths in nginx ingress

how do I achieve something similar to this.我如何实现与此类似的东西。

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: /

Is there any way to capture the matching word in the subdomain and append it in the path before routing to the upstream service.在路由到上游服务之前,有什么方法可以捕获子域中的匹配词和路径中的 append。

From the official doc:来自官方文档:

Regular expressions and wild cards are not supported in the spec.rules.host field. spec.rules.host字段不支持正则表达式和通配符。 Full hostnames must be used.必须使用完整的主机名。

See: nginx-ingress-matching .请参阅: nginx-ingress-matching

However I have found similar problem which advice to write your own controller that writes out an nginx config that uses $http_host in the appropriate proxy_pass or redirect lines.但是我发现了类似的问题,建议编写您自己的 controller 写出一个 nginx 配置,该配置在适当的proxy_pass或重定向行中使用$http_host

Read more: wildcard-url-mapping .阅读更多: 通配符 url 映射

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM