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

Always get 404 accessing my nginx backend service #1112

Closed
xinxiaogang opened this issue Feb 4, 2017 · 3 comments
Closed

Always get 404 accessing my nginx backend service #1112

xinxiaogang opened this issue Feb 4, 2017 · 3 comments

Comments

@xinxiaogang
Copy link

What version of Traefik are you using (traefik version)?

Lastest docker image, it should be v1.1.2

What is your environment & configuration (arguments, toml...)?

I deploy traefik as the Ingress controller in my kubernetes cluster.
My toml:

    # traefik.toml
    defaultEntryPoints = ["http","https"]
    [entryPoints]
      [entryPoints.http]
      address = ":80"
        [entryPoints.http.redirect]
          entryPoint = "https"
      [entryPoints.https]
      address = ":443"
        [entryPoints.https.tls]
          [[entryPoints.https.tls.certificates]]
          CertFile = "/ssl/tls.crt"
          KeyFile = "/ssl/tls.key"
    [web]
    address = ":8080"
    ReadOnly = true

My arguments:

        args:
        - --configfile=/config/traefik.toml
        - --web
        - --kubernetes
        - --kubernetes.namespaces=ciaas-qa
        - --logLevel=DEBUG

What did you do?

I want to use traefik for my TLS termination at L7 level. My real service is provided by a nginx pod. I create Ingress spec as below:

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

But I get 404 when accessing https://ingress.ciaas-qa.svc.33.tess.io/my-nginx. ingress.ciaas-qa.svc.33.tess.io is my ingress service DNS record.

What did you expect to see?

I should see the nginx welcome page.

What did you see instead?

I got 404 page from my nginx:

<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.11.9</center>
</body>
</html>

More info:

Here is the traefik configuration I get from the API:

// 20170204203405
// http://ingress-console.ciaas-qa.svc.33.tess.io:8080/api/providers/kubernetes

{
  "backends": {
    "/my-nginx": {
      "servers": {
        "my-nginx-379829228-9eylj": {
          "url": "http://10.148.168.235:80",
          "weight": 0
        }
      },
      "loadBalancer": {
        "method": "wrr"
      }
    }
  },
  "frontends": {
    "/my-nginx": {
      "entryPoints": [
        "http",
        "https"
      ],
      "backend": "/my-nginx",
      "routes": {
        "/my-nginx": {
          "rule": "PathPrefix:/my-nginx"
        }
      },
      "passHostHeader": true,
      "priority": 9
    }
  }
}

my-nginx-379829228-9eylj is my nginx pod name, 10.148.168.235 is the nginx pod IP. And I can get expected welcome page if I use http://10.148.168.235:80 directly in the browser. But use https://ingress.ciaas-qa.svc.33.tess.io/my-nginx get 404.

@dtomcej
Copy link
Contributor

dtomcej commented Feb 10, 2017

The PathPrefix:/my-nginx rule that is automatically generated to match your /my-nginx ingress path does not strip the path. Therefore, the /my-nginx of the request gets passed to your pod, which in turn returns the 404.

@regner
Copy link
Contributor

regner commented Feb 10, 2017

Adding traefik.frontend.rule.type: pathprefixstrip to the annotations of the Ingress will cause the /my-nginx path to be stripped out of the request to NGINX.

@xinxiaogang
Copy link
Author

Thanks for pointing out, fixed.

@traefik traefik locked and limited conversation to collaborators Sep 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants