Answers: <p>I believe you are encountering the Nginx Ingress Controller's &quot;<a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#strict-validate-path-type" rel="nofollow noreferrer">strict-validate-path-type</a>&quot; check, <strong>which is enabled by default</strong>. When this option is enabled, there is strict validation of <code>Exact</code> and <code>Prefix</code> types, only allowing:</p>
  <blockquote>
  <p>alphanumeric characters and &quot;-&quot;, &quot;_&quot; and additional &quot;/&quot;.</p>
  </blockquote>
  <p>I would try changing the type to <code>ImplementationSpecific</code>.</p>
  <p>The other option would be to update the Nginx Ingress Controller <code>ConfigMap</code> to set <code>strict-validate-path-type: &quot;false&quot;</code>. Make sure to restart the controller pod(s) after this change.</p>
  <p>Also, the regex syntax may have changed since the Udemy example was created, here is the <a href="https://kubernetes.github.io/ingress-nginx/user-guide/ingress-path-matching/" rel="nofollow noreferrer">latest docs on regex in path matching</a>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2024-11-22T16:48:49.217Z
Answers: 2024-11-22T16:49:26.213Z
Answers: 2024-11-22T16:49:26.213Z
Answers: Jason Snouffer
Body: <p>I'm trying to deploy this ingress service on AWS EKS. it works locally, but not when deployed to EKS.</p>
  <pre><code>apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: ingress-service
    annotations:
      kubernetes.io/ingress.class: nginx
      nginx.ingress.kubernetes.io/use-regex: 'true'
      nginx.ingress.kubernetes.io/rewrite-target: /$1
  spec:
    rules:
      - host: a16a5f3b82c3b4cf0a27a801c8b43788-1a53212dd4e2fc34.elb.ca-central-1.amazonaws.com
        http:
          paths:
            - path: /?(.*)
              pathType: Prefix
              backend:
                service:
                  name: store-cluster-ip-service
                  port:
                    number: 80
            - path: /api/?(.*)
              pathType: Prefix
              backend:
                service:
                  name: products-api-cluster-ip-service
                  port:
                    number: 5002
  
  </code></pre>
  <p>I'm getting the following errors.</p>
  <pre><code>Warning: annotation &quot;kubernetes.io/ingress.class&quot; is deprecated, please use 'spec.ingressClassName' instead
  Warning: path /?(.*) cannot be used with pathType Prefix
  Warning: path /api/?(.*) cannot be used with pathType Prefix
  Error from server (BadRequest): error when creating &quot;ingress-service.yaml&quot;: admission webhook &quot;validate.nginx.ingress.kubernetes.io&quot; denied the request: ingress contains invalid paths: path /?(.*) cannot be used with pathType Prefix
  path /api/?(.*) cannot be used with pathType Prefix
  </code></pre>
  <p>I'm following an outdated course on udemy so the first warning i'm aware i have to change to using an ingress class, but why are the second two errors happening? Are they related to the first issue (ingress Class)?</p>
  
Tags: <kubernetes><amazon-web-services><eks>
Title: ingress failing due to error: path /?(.*) cannot be used with pathType Prefix
UserDisplayName: SlowBlurry
ThreadText: # ingress failing due to error: path /?(.*) cannot be used with pathType Prefix
  
  (Asked by: username_0 on 2024-11-21)
  
  I'm trying to deploy this ingress service on AWS EKS. it works locally, but not when deployed to EKS.
  
  ```
  apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: ingress-service
    annotations:
      kubernetes.io/ingress.class: nginx
      nginx.ingress.kubernetes.io/use-regex: 'true'
      nginx.ingress.kubernetes.io/rewrite-target: /$1
  spec:
    rules:
      - host: a16a5f3b82c3b4cf0a27a801c8b43788-1a53212dd4e2fc34.elb.ca-central-1.amazonaws.com
        http:
          paths:
            - path: /?(.*)
              pathType: Prefix
              backend:
                service:
                  name: store-cluster-ip-service
                  port:
                    number: 80
            - path: /api/?(.*)
              pathType: Prefix
              backend:
                service:
                  name: products-api-cluster-ip-service
                  port:
                    number: 5002
  
  ```
  
  I'm getting the following errors.
  
  ```
  Warning: annotation "kubernetes.io/ingress.class" is deprecated, please use 'spec.ingressClassName' instead
  Warning: path /?(.*) cannot be used with pathType Prefix
  Warning: path /api/?(.*) cannot be used with pathType Prefix
  Error from server (BadRequest): error when creating "ingress-service.yaml": admission webhook "validate.nginx.ingress.kubernetes.io" denied the request: ingress contains invalid paths: path /?(.*) cannot be used with pathType Prefix
  path /api/?(.*) cannot be used with pathType Prefix
  
  ```
  
  I'm following an outdated course on udemy so the first warning i'm aware i have to change to using an ingress class, but why are the second two errors happening? Are they related to the first issue (ingress Class)?
  
  **Tags:** kubernetes, amazon-web-services, eks
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-11-22. Score: 0
  
  I believe you are encountering the Nginx Ingress Controller's "[strict-validate-path-type](https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#strict-validate-path-type)" check, **which is enabled by default**. When this option is enabled, there is strict validation of `Exact` and `Prefix` types, only allowing:
  
  > alphanumeric characters and "-", "\_" and additional "/".
  
  I would try changing the type to `ImplementationSpecific`.
  
  The other option would be to update the Nginx Ingress Controller `ConfigMap` to set `strict-validate-path-type: "false"`. Make sure to restart the controller pod(s) after this change.
  
  Also, the regex syntax may have changed since the Udemy example was created, here is the [latest docs on regex in path matching](https://kubernetes.github.io/ingress-nginx/user-guide/ingress-path-matching/).
  
  
  ---
  
  