Skip to content

nginx.org/rewrites not support regex with mergeable-ingress-type #6892

@zhigang-guo

Description

@zhigang-guo

Version

3.7.0

What Kubernetes platforms are you running on?

AKS Azure

Steps to reproduce

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: "nginx-ingress-${ENVIRONMENT}-master"
  namespace: ${NAMESPACE}
  annotations:
    nginx.org/mergeable-ingress-type: "master"
    nginx.org/hsts: "true"
    nginx.org/hsts-max-age: "31536000"
    nginx.org/server-tokens: "false"
    nginx.org/hsts-include-subdomains: "true"
    # nginx.org/location-snippets: |
    #   add_header Set-Cookie "Path=/${PROJECT_CODE}-${ENVIRONMENT}; HttpOnly; Secure; SameSite=Strict";
    #   add_header Cache-Control "no-transform";
    #   add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; font-src 'self'; base-uri 'self'; object-src 'none'; frame-src 'self'; img-src 'self' data:; manifest-src 'self'; media-src 'self'";
    #   add_header Content-Security-Policy upgrade-insecure-requests;
    nginx.org/server-snippets: |
      error_page 404 /404.html;
      location = /404.html {
        internal;
        alias /usr/share/nginx/html/custom-404.html;
      }
spec:
  ingressClassName: "nginx-ingress-${ENVIRONMENT}"
  tls:
    - hosts:
        - "test.com"
      secretName: "cert-${ENVIRONMENT}"
  rules:
    - host: "test.com"
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: "nginx-ingress-${ENVIRONMENT}-testapp-minion"
  namespace: ${NAMESPACE}
  annotations:
    nginx.org/mergeable-ingress-type: "minion"
    nginx.org/rewrites: "serviceName=test-service rewrite=/testapp$2"
spec:
  ingressClassName: "nginx-ingress-${ENVIRONMENT}"
  rules:
    - host: "test.com"
      http:
        paths:
          - path: "/app/test/api(/|$)(.*)"
            pathType: Prefix
            backend:
              service:
                name: test-service
                port:
                  number: 3001

Applied above config. but got error "annotations.nginx.org/rewrites: Invalid value: "serviceName=test-service rewrite=/testapp$2": path must start with '/' and must not include any whitespace character, '{', '}' or '$': '/testapp$2'"

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/apigatewayIssues related to API Gateway capabilitiesarea/ingressIssues related to changes in `kind: Ingress`proposalAn issue that proposes a feature requestready for refinementAn issue that was triaged and it is ready to be refined

    Projects

    Status

    Prioritized backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions