【问题标题】:routing wildcard domain to different paths in nginx ingress将通配符域路由到 nginx 入口中的不同路径
【发布时间】:2021-01-14 14:13:01
【问题描述】:

我如何实现类似的效果。

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

有什么办法可以捕获子域中的匹配词,并在路由到上游服务之前将其附加到路径中。

【问题讨论】:

    标签: nginx kubernetes-ingress nginx-ingress


    【解决方案1】:

    来自官方文档:

    不支持正则表达式和通配符 spec.rules.host 字段。必须使用完整的主机名。

    请参阅:nginx-ingress-matching

    但是我发现了类似的问题,建议编写自己的控制器,在适当的 proxy_pass 或重定向行中写出使用 $http_host 的 nginx 配置。

    阅读更多:wildcard-url-mapping

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-27
      • 2020-11-14
      • 1970-01-01
      • 2018-07-22
      • 1970-01-01
      • 2020-12-30
      • 2021-12-27
      相关资源
      最近更新 更多