Answers: <p>Apparently - I forgot annotations and ingressclass:</p>
  <p>I first added this:</p>
  <pre><code>apiVersion: networking.k8s.io/v1
  kind: IngressClass
  metadata:
    annotations:
      ingressclass.kubernetes.io/is-default-class: &quot;true&quot;
    generation: 1
    labels:
      app.kubernetes.io/component: controller
      app.kubernetes.io/instance: haproxy
      app.kubernetes.io/managed-by: Helm
      app.kubernetes.io/name: haproxy-ingress-controller
    name: haproxy
  spec:
    controller: haproxy.org/ingress-controller
  </code></pre>
  <p>And in the ingress:</p>
  <pre><code>apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: notesncrap
    annotations:
      kubernetes.io/ingress.class: &quot;haproxy&quot;
    generation: 1
  spec:
    rules:
    - host: k8scrap.selea.se
      http:
        paths:
        - path: /
          backend:
            serviceName: notesncrap
            servicePort: 80
  </code></pre>
  <p>Please observe the annotation.</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-01-23T10:48:27.720Z
Answers: 2022-01-23T10:48:27.720Z
Answers: Orphans
Body: <p>I am currently running a small <a href="https://k3s.io/" rel="nofollow noreferrer">K3S cluster</a> in order to get familiar with K8S.</p>
  <p>I am able to set up pods with ordinary LoadBalancers and get it to work without any problem.
  However, when I try to get it to work with Ingresses (HAProxy in my case) - I only end up with &quot;default backend -404&quot;.</p>
  <p>This is the deployment of the pods, based on the default NGINX container:</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: notesncrap
    labels:
      app: notesncrap
  spec:
    replicas: 2
    selector:
      matchLabels:
        app: notesncrap
    template:
      metadata:
        labels:
          app: notesncrap
      spec:
        containers:
        - name: notesncrap
          image: jselea/notesncrap 
          ports:
          - containerPort: 80
  </code></pre>
  <p>I have also created a Service:</p>
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: notesncrap
    labels:
      app: notesncrap
  spec:
    ports:
      - port: 80
    selector:
      app: notesncrap
      tier: frontend
  </code></pre>
  <p>And now the Ingress:</p>
  <pre><code>apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: notesncrap
  spec:
    rules:
    - host: k8scrap.selea.se
      http:
        paths:
        - path: /
          backend:
            serviceName: notesncrap
            servicePort: 80
  </code></pre>
  <p>I have the understanding that the name and label should be consistent over the .yaml files, and I personally can't see anything really wrong with what I have written.</p>
  <p>Thankful for any pointers</p>
  <p>EDIT:</p>
  <p>As pointed out by the comments - the Ingress is behind a Apache Reverseproxy:</p>
  <pre><code>ProxyPass &quot;/&quot; &quot;http://x.x.x.x:80&quot;
  ProxyPassReverse &quot;/&quot; &quot;http://x.x.x.x:80&quot;
  ProxyRequests On
  ProxyPreserveHost On
  </code></pre>
  <p>When I try curl directly against the ingress:</p>
  <pre><code>╭─root@sshgateway ~
  ╰─➤  curl -H &quot;Host:k8scrap.selea.se&quot; http://x.x.x.x                                                                                                                                   
  default backend - 404#
  </code></pre>
  
Comments: CC BY-SA 4.0
Comments: 2022-01-04T12:30:49.170Z
Comments: are you sure that Host is `k8scrap.selea.se` ? 
  I think that HTTP headers would be helpful in this case
Comments: confiq
Comments: CC BY-SA 4.0
Comments: 2022-01-04T14:54:26.877Z
Comments: @confiq you are correct; I already checked. Seems like default Apache Ubuntu server is being hit instead of the "app" - `< server: Apache/2.4.52 (Ubuntu)`.
Comments: Kyslik
Comments: CC BY-SA 4.0
Comments: 2022-01-05T07:05:01.143Z
Comments: @Kyslik Apache is used as a reverseproxy in front of it. I have also tested with "curl -H "Host:k8scrap.selea.se" " against the ingress directly
Comments: Orphans
Tags: <ingress><rancher>
Title: default backend - 404
UserDisplayName: Orphans
ThreadText: # default backend - 404
  
  (Asked by: username_0 on 2022-01-04)
  
  I am currently running a small [K3S cluster](https://k3s.io/) in order to get familiar with K8S.
  
  I am able to set up pods with ordinary LoadBalancers and get it to work without any problem.
  However, when I try to get it to work with Ingresses (HAProxy in my case) - I only end up with "default backend -404".
  
  This is the deployment of the pods, based on the default NGINX container:
  
  ```
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: notesncrap
    labels:
      app: notesncrap
  spec:
    replicas: 2
    selector:
      matchLabels:
        app: notesncrap
    template:
      metadata:
        labels:
          app: notesncrap
      spec:
        containers:
        - name: notesncrap
          image: jselea/notesncrap 
          ports:
          - containerPort: 80
  
  ```
  
  I have also created a Service:
  
  ```
  apiVersion: v1
  kind: Service
  metadata:
    name: notesncrap
    labels:
      app: notesncrap
  spec:
    ports:
      - port: 80
    selector:
      app: notesncrap
      tier: frontend
  
  ```
  
  And now the Ingress:
  
  ```
  apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: notesncrap
  spec:
    rules:
    - host: k8scrap.selea.se
      http:
        paths:
        - path: /
          backend:
            serviceName: notesncrap
            servicePort: 80
  
  ```
  
  I have the understanding that the name and label should be consistent over the .yaml files, and I personally can't see anything really wrong with what I have written.
  
  Thankful for any pointers
  
  EDIT:
  
  As pointed out by the comments - the Ingress is behind a Apache Reverseproxy:
  
  ```
  ProxyPass "/" "http://x.x.x.x:80"
  ProxyPassReverse "/" "http://x.x.x.x:80"
  ProxyRequests On
  ProxyPreserveHost On
  
  ```
  
  When I try curl directly against the ingress:
  
  ```
  ╭─root@sshgateway ~
  ╰─➤  curl -H "Host:k8scrap.selea.se" http://x.x.x.x                                                                                                                                   
  default backend - 404#
  
  ```
  
  **Tags:** ingress, rancher
  
  > **Comments:**
  > **username_1**: are you sure that Host is `k8scrap.selea.se` ?  I think that HTTP headers would be helpful in this case  
  > **username_2**: @username_1 you are correct; I already checked. Seems like default Apache Ubuntu server is being hit instead of the "app" - `< server: Apache/2.4.52 (Ubuntu)`.  
  > **username_0**: @username_2 Apache is used as a reverseproxy in front of it. I have also tested with "curl -H "Host:k8scrap.selea.se" " against the ingress directly  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2022-01-23. Score: 0 | Accepted answer
  
  Apparently - I forgot annotations and ingressclass:
  
  I first added this:
  
  ```
  apiVersion: networking.k8s.io/v1
  kind: IngressClass
  metadata:
    annotations:
      ingressclass.kubernetes.io/is-default-class: "true"
    generation: 1
    labels:
      app.kubernetes.io/component: controller
      app.kubernetes.io/instance: haproxy
      app.kubernetes.io/managed-by: Helm
      app.kubernetes.io/name: haproxy-ingress-controller
    name: haproxy
  spec:
    controller: haproxy.org/ingress-controller
  
  ```
  
  And in the ingress:
  
  ```
  apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: notesncrap
    annotations:
      kubernetes.io/ingress.class: "haproxy"
    generation: 1
  spec:
    rules:
    - host: k8scrap.selea.se
      http:
        paths:
        - path: /
          backend:
            serviceName: notesncrap
            servicePort: 80
  
  ```
  
  Please observe the annotation.
  
  
  ---
  
  