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

k8s_matches_pathtype_prefix incorrectly handles locations with trailing slash #6463

Closed
ichaozai opened this issue Nov 12, 2020 · 1 comment
Closed
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@ichaozai
Copy link

NGINX Ingress controller version: 0.41.0

Kubernetes version (use kubectl version): v1.17.5

Environment:

  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release): Ubuntu 16.04.6 LTS
  • Kernel (e.g. uname -a): 4.4.0-142-generic
  • Install tools: kubeadm
  • Others:

What happened:

With following Ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
  name: an-ingress
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: a-service
          servicePort: 80
        path: /prefix/

Got HTTP 404 when accessing /prefix/foo/bar.

What you expected to happen:

Path with a trailing slash should work as the prefix.

When I turn on debug log level:

2020/11/12 09:25:47 [debug] 72368#72368: *3797004 code cache lookup (key='rewrite_by_lua_nhli_d8124e310757dec7b05144568a4babe7', ref=-1)
2020/11/12 09:25:47 [debug] 72368#72368: *3797004 code cache miss (key='rewrite_by_lua_nhli_d8124e310757dec7b05144568a4babe7', ref=-1)
2020/11/12 09:25:47 [debug] 72368#72368: *3797004 lua creating new thread
2020/11/12 09:25:47 [debug] 72368#72368: *3797004 lua reusing cached lua thread 00007FE683EDB5E0 (ref 2)
2020/11/12 09:25:47 [debug] 72368#72368: *3797004 lua reset ctx
2020/11/12 09:25:47 [debug] 72368#72368: *3797004 http lua finalize threads
2020/11/12 09:25:47 [debug] 72368#72368: *3797004 http cleanup add: 00005609E27EBDB0
2020/11/12 09:25:47 [debug] 72368#72368: *3797004 lua run thread, top:0 c:1
2020/11/12 09:25:47 [debug] 72368#72368: *3797004 lua exit with code 404
2020/11/12 09:25:47 [debug] 72368#72368: *3797004 lua resume returned 1

It exits with HTTP 404 from lua_ingress.rewrite(), which call k8s_matches_pathtype_prefix()
https://github.com/kubernetes/ingress-nginx/blob/controller-v0.41.0/rootfs/etc/nginx/lua/lua_ingress.lua#L100-L117

It should ignore the trailing slash at the beginning.

How to reproduce it:

Anything else we need to know:

/kind bug

@ichaozai ichaozai added the kind/bug Categorizes issue or PR as related to a bug. label Nov 12, 2020
@aledbf
Copy link
Member

aledbf commented Nov 12, 2020

Closing. Fixed in #6443

@aledbf aledbf closed this as completed Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

2 participants