Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: nginx.org/rewrites not support regex with mergeable-ingress-type #6892

Open
zhigang-guo opened this issue Dec 3, 2024 · 2 comments
Open
Labels
bug An issue reporting a potential bug needs triage An issue that needs to be triaged

Comments

@zhigang-guo
Copy link

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'"

@zhigang-guo zhigang-guo added bug An issue reporting a potential bug needs triage An issue that needs to be triaged labels Dec 3, 2024
Copy link

github-actions bot commented Dec 3, 2024

Hi @zhigang-guo thanks for reporting!

Be sure to check out the docs and the Contributing Guidelines while you wait for a human to take a look at this 🙂

Cheers!

@jjngx
Copy link
Contributor

jjngx commented Dec 4, 2024

@zhigang-guo this is expected behavior. The rewrites annotation example: link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue reporting a potential bug needs triage An issue that needs to be triaged
Projects
Status: Todo ☑
Development

No branches or pull requests

2 participants