How provide correct path for GCE Ingress without wildcard?

7/3/2019

I have deployment with wordpress and I want provide this deployment on https:///blog.

rules:
  - host: <domain>
    http:
      paths:
      - backend:
          serviceName: backend
          servicePort: 80
        path: /*
      - backend:
          serviceName: wordpress
          servicePort: 80
        path: /blog/*

But gce ingress doesn't allow proxy traffic without wildcard. My blog available on /blog/, but not on /blog.

Can I somehow fix that problem? Thanks.

-- Serhii Koberniuk
google-kubernetes-engine
kubernetes-ingress
nginx-ingress

1 Answer

7/4/2019

As per documentation:

Starting in Version 0.22.0, ingress definitions using the annotation nginx.ingress.kubernetes.io/rewrite-target are not backwards compatible with previous versions. In Version 0.22.0 and beyond, any substrings within the request URI that need to be passed to the rewritten path must explicitly be defined in a capture group.

with the example for rewrite-target:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: rewrite
  namespace: default
spec:
  rules:
  - host: rewrite.bar.com
    http:
      paths:
      - backend:
          serviceName: http-svc
          servicePort: 80
        path: /something(/|$)(.*) 

Resources:

Hope this help.

-- Hanx
Source: StackOverflow