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

Paths using regex containing the $ character need to be escaped when setting $location_path in the nginx template #3191

Closed
bshelton229 opened this issue Oct 5, 2018 · 2 comments · Fixed by #3194

Comments

@bshelton229
Copy link
Contributor

Is this a request for help? (If yes, you should use our troubleshooting guide and community support channels, see https://kubernetes.io/docs/tasks/debug-application-cluster/troubleshooting/.):

What keywords did you search in NGINX Ingress controller issues before filing this one? (If you have found any duplicates, you should instead reply there.):


Is this a BUG REPORT or FEATURE REQUEST? (choose one):

NGINX Ingress controller version: unreleased

Kubernetes version (use kubectl version): 1.10

Environment:

  • Cloud provider or hardware configuration: AWS
  • OS (e.g. from /etc/os-release): Amazon Linux 2
  • Kernel (e.g. uname -a): 4.14.62-70.117.amzn2.x86_64
  • Install tools: AWS EKS
  • Others:

What happened:

The emerging support for regex paths is really awesome! Thanks @zrdaley . We've been using a custom template in testing to achieve this so far and are really happy to know we'll be able to avoid that. We have a couple paths that contain $ in the regex pattern. For example, we have one called "homepage" which only receives traffic from /, in which case we're using /$ to end up with location ~* "^/$" {.....

When there is a $ character in path it causes nginx errors from the following template declaration - set $location_path "{{ $location.Path }}"; because nginx variables can't contain $. I've yet to be able to find a way to escape an actual $ character in an nginx variable. I'll open a PR with what we're currently doing in testing to get this working in order to get a conversation started.

What you expected to happen:

It would be nice to support $ in regex enabled paths and have the $location_path nginx variable contain something escaped in some way.

How to reproduce it (as minimally and precisely as possible):

Fulfilling an ingress resource with a path containing a $ should be enough to reproduce the issue.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: hello-world-ingress
  labels:
    app: hello-world-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  rules:
    - host: hello-world.example.com
      http:
        paths:
          - path: /hello$
            backend:
              serviceName: my-service-hello-only
              servicePort: http
          - path: /
            backend:
              serviceName: my-service
              servicePort: http

This should fail to reload or boot nginx with an error like:

2018/10/05 18:00:59 [emerg] 95#95: invalid variable name in /tmp/nginx-cfg577284661:398

Anything else we need to know:

@zrdaley
Copy link
Contributor

zrdaley commented Oct 5, 2018

Which controller version are you using? This issue should have been fixed here: #3182.

Version 0.20.0 will have this update.

@bshelton229
Copy link
Contributor Author

I've been building master. I'm currently seeing this from b46523a. Before the regex work landed in master we were using a custom template that did something similar to what's now done in the controller and ran into this same issue there. Given we were using a custom template we just removed that set as we didn't need the variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants