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

Annotation configuration-snippet not working with basic-auth #3661

Closed
ghost opened this issue Jan 13, 2019 · 8 comments
Closed

Annotation configuration-snippet not working with basic-auth #3661

ghost opened this issue Jan 13, 2019 · 8 comments

Comments

@ghost
Copy link

ghost commented Jan 13, 2019

This is a BUG REPORT

NGINX Ingress controller version: 0.21.0

Kubernetes version:

Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"eec55b9ba98609a46fee712359c7b5b365bdd920", GitTreeState:"clean", BuildDate:"2018-12-13T19:44:19Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.6", GitCommit:"b1d75deca493a24a2f87eb1efde1a569e52fc8d9", GitTreeState:"clean", BuildDate:"2018-12-16T04:30:10Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}

Environment:

  • Cloud provider or hardware configuration: AWS
  • OS (e.g. from /etc/os-release): Debian Stretch
  • Install tools: kops, helm

What happened:

After upgrading nginx-ingress to 0.21.0 from 0.19.0 locations in configuration-snippet annotations don't work.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/auth-realm: Authentication Required
    nginx.ingress.kubernetes.io/auth-secret: basic-auth
    nginx.ingress.kubernetes.io/auth-type: basic
    nginx.ingress.kubernetes.io/configuration-snippet: |
      location ~ favicon.ico {
        auth_basic off;
        proxy_pass $backend_service;
      }

What you expected to happen:

Nginx Ingress 0.19:
curl https://domain.org/favicon.ico -Is | head -1
HTTP/2 200 

Nginx Ingress 0.21:
curl https://domain.org/favicon.ico -Is | head -1
HTTP/2 503 

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

Use configuration-snippet annotation on 0.21.0 with basic auth.

Anything else we need to know:

If we change location to:

...
    nginx.ingress.kubernetes.io/configuration-snippet: |
      location ~ favicon.ico {
        return 200 "Hello";
      }

Location works:

$ curl https://domain.org/favicon.ico
Hello
@aledbf
Copy link
Member

aledbf commented Jan 13, 2019

$backend_service;

Where are you defining that variable? Keep in mind you cannot create upstreams manually because the load balancing part is being done in lua with configuration sent from the controller (go)

@ghost
Copy link
Author

ghost commented Jan 13, 2019

I'm defining it in annotation too (server-snippet):

nginx.ingress.kubernetes.io/server-snippet: "set $backend_service http://my-dynamic-backend;"

@aledbf
Copy link
Member

aledbf commented Jan 13, 2019

@AmetPreply if you want to route to an external server, you need to use a service type=ExternalName.
Please check #629 (comment)

@aledbf
Copy link
Member

aledbf commented Jan 13, 2019

Closing. This works as expected. The lua balancing cannot be bypassed unless you use a custom template, changing the behavior of balancer_by_lua_block.

@aledbf aledbf closed this as completed Jan 13, 2019
@ghost
Copy link
Author

ghost commented Jan 13, 2019

Ok.
I'll ask another question.
In 0.19.0 default location is:

location / {
}

In 0.21.0 default location is:

location ~* "^/" {
}

So my nested locations can't work with new parent location. How can I change my ingress for working with new parent location?

@aledbf
Copy link
Member

aledbf commented Jan 13, 2019

location ~* "^/" {

That is true only if you use the regex annotation. From the output you posted, why are you enabling a regex for / ?

@Amet13
Copy link

Amet13 commented Jan 13, 2019

I set it to false but it still generates such type of location:

nginx.ingress.kubernetes.io/use-regex: "false"

@ghost
Copy link
Author

ghost commented Jan 13, 2019

Ok. I found difference with, location ~* "^/" { it was because I have another ingress.
Thanks for help, I will try investigate my problem again.

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

No branches or pull requests

2 participants