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

default route is wrong #52

Closed
jacek-marchwicki opened this issue Sep 28, 2016 · 4 comments
Closed

default route is wrong #52

jacek-marchwicki opened this issue Sep 28, 2016 · 4 comments

Comments

@jacek-marchwicki
Copy link

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: cafe-ingress
spec:
  tls:
  - hosts:
    - cafe.minikube
    - tea.minikube
    - coffee.minikube
    secretName: cafe-secret
  rules:
  - host: tea.minikube
    http:
      paths:
      - path: /
        backend:
          serviceName: tea-svc
          servicePort: 80
  - host: coffee.minikube
    http:
      paths:
      - path: /
        backend:
          serviceName: coffee-svc
          servicePort: 80
  - host: cafe.minikube
    http:
      paths:
      - path: /tea
        backend:
          serviceName: tea-svc
          servicePort: 80
      - path: /coffee
        backend:
          serviceName: coffee-svc
          servicePort: 80

in this example:

  • https://cofee.minikube/ gives coffee-rc-XYZ (correct)
  • https://cafe.minikube/coffee gives coffee-rc-XYZ (correct)
  • https://cafe.minikube/tea gives tea-rc-XYZ (correct)
  • https://wrong.minikube/ gives coffee-rc-XYZ (WRONG) it should return 404
@pleshakov
Copy link
Contributor

Currently, the controller doesn't include the default server, which catches all HTTP/HTTPS requests with a host header that doesn't match any of the Ingress hosts. Thx for pointing that out. We'll add it.

@pleshakov
Copy link
Contributor

pleshakov commented Nov 4, 2016

@jacek-marchwicki
I can suggest the following solution. We define an Ingress resource that exposes a service that handles all requests with a value of the host header that doesn't match any of the existing Ingress hosts. We also setup SSL termination to handle HTTPS requests.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: default-ingress
annotations:
  nginx.org/default-server: "true"
spec:
  tls:
    - secretName: default-secret
  backend:
    serviceName: default-service
    servicePort: 80

Note that we don't define any Ingress rules, just a default backend without a hostname. The nginx.org/default-server annotation tells NGINX to create a default server.

This way you can create a custom service that returns 404s or other things if you want.

Let me know your thoughts.

@jacek-marchwicki
Copy link
Author

@pleshakov pretty hacky but if it works it's good quick fix ;)

Thank you!

@pleshakov
Copy link
Contributor

@jacek-marchwicki
great. we'll add the annotation to the NGINX controller and examples. I'll let you know once it's available

jmastr pushed a commit to endocode/kubernetes-ingress that referenced this issue Dec 14, 2016
Ideally, this feature should be a part of a bigger feature (the default
server) that solves nginx#52.

For now, we add the "-health-status" parameter to the controller. If
it is present, the default server listening on port 80 with the health
check location "/nginx-health" gets added to the main nginx
configuration.

Closes nginx#90
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