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

Any path other than "/", e.g. "/foo", and any route other than "/foo" is 404 #3298

Closed
charlesritchea opened this issue Oct 25, 2018 · 10 comments

Comments

@charlesritchea
Copy link

charlesritchea commented Oct 25, 2018

I have a dropwizard server with an application port and an admin port. I'm trying to get the application on / and the admin on /admin, but I can only get the application to work for all links. Admin only works for the root page of the admin service.

So I tried to simplify it and I'm just trying to get a single service on /foo, but only the root /foo link works. All other links strip the /foo part and are 404.

Maybe I'm missing something, but this seems to be the whole point of ingress, so I'm a bit baffled.

Am I supposed to configure my backend service to expect this different root path?

I thought if you just had a service with 3 ports, you could just map them to /, /foo, /bar respectively.
This is what I set out to do:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    certmanager.k8s.io/cluster-issuer: letsencrypt-staging
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
  creationTimestamp: null
  generation: 1
  name: blah-ingress
  selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/blah-ingress
spec:
  rules:
  - host: blah-ingress.eastus.cloudapp.azure.com
    http:
      paths:
      - backend:
          serviceName: blah-service
          servicePort: 11110
        path: /
      - backend:
          serviceName: blah-service
          servicePort: 11111
        path: /foo
  tls:
  - hosts:
    - blah-ingress.eastus.cloudapp.azure.com
    secretName: tls-secret
status:
  loadBalancer: {}

But I thought maybe the paths being on the same service was an issue, so tried this:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    certmanager.k8s.io/cluster-issuer: letsencrypt-staging
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
  creationTimestamp: null
  generation: 1
  name: blah-ingress
  selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/blah-ingress
spec:
  rules:
  - host: blah-ingress.eastus.cloudapp.azure.com
    http:
      paths:
      - backend:
          serviceName: blah-service
          servicePort: 11110
        path: /foo
  tls:
  - hosts:
    - blah-ingress.eastus.cloudapp.azure.com
    secretName: tls-secret
status:
  loadBalancer: {}
@charlesritchea
Copy link
Author

I was following along with https://docs.microsoft.com/en-us/azure/aks/ingress-tls
I've seen similar issues filed, but nothing in them explained this problem in a way I could understand.

@charlesritchea
Copy link
Author

Ok, so the secondary routes do work if I explicitly curl them like http://my-host/admin/metrics works, but all the links produced by my service are still http://my-host/metrics. I can't tell if this is the responsibility of ingress or of my service. Is this working as intended? Is rewrite-target causing this? Because nothing works if I remove rewrite-target (and I'm unclear on it's purpose if it's required)

@charlesritchea
Copy link
Author

I needed to set my context path, specifically adminContextPath in dropwizard, so that it knows to start from /admin instead of /. I'm closing, I really wished ingress documentation (not just here, but everywhere) mentioned that you have to also configure your service with the new path as well. It's not obvious. To me it's implied that this is automatic, and for some reason ALL examples (not just here but everywhere I looked) have a topology of a single page with no structure.

@aledbf
Copy link
Member

aledbf commented Oct 29, 2018

. I'm closing, I really wished ingress documentation (not just here, but everywhere) mentioned that you have to also configure your service with the new path as well.

Please check https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#rewrite

@charlesritchea
Copy link
Author

@aledbf Yes, I'm using that annotation as can be seen above. It did not work for the secondary route as explained.

@charlesritchea
Copy link
Author

@aledbf are you trying to say I need to do this:

If the application contains relative links it is possible to add an additional annotation nginx.ingress.kubernetes.io/add-base-url that will prepend a base tag in the header of the returned HTML from the backend.

If the scheme of base tag need to be specific, set the annotation nginx.ingress.kubernetes.io/base-url-scheme to the scheme such as http and https.

If the Application Root is exposed in a different path and needs to be redirected, set the annotation nginx.ingress.kubernetes.io/app-root to redirect requests for /.

?

@charlesritchea
Copy link
Author

@aledbf And that example does not use those annotation. It's like a riddle

@aledbf
Copy link
Member

aledbf commented Oct 29, 2018

And that example does not use those annotation. It's like a riddle

I am sorry for that but we cannot provide examples for all the annotations. Please keep in mind this is a community project.

@charlesritchea
Copy link
Author

@aledbf Yes, I don't want to be a bother anymore hence why I closed the issue, but I'm just letting you know that what seems to me a very simple ingress setup does not work in how I imagined it and I can't figure it out based on the documentation. I'm afraid everyone involved is too familiar with the technology and jargon to explain it to me. Hopefully I can get it to work by setting the adminContextPath in dropwizard; otherwise, I'm going to have to use an nginx-ssl-proxy or similar

@suujia
Copy link

suujia commented Nov 9, 2018

I got the same error and found your issue first. After some more googling I found this good resolution: #1120 (comment)

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

3 participants