<p>Accessing my nodejs/react site using the URL displays "Invalid Host header". Accessing it through the public IP displays "default backend - 404".</p>

<p>I am using Kubernetes nginx controller with Azure cloud and load balancer.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: myrule
  namespace: mynamespace
  annotations:
    kubernetes.io/ingress.class: nginx
    certmanager.k8s.io/cluster-issuer: letsencrypt-staging
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  tls:
  - hosts:
    - mysite.uknorth.cloudapp.azure.com
    secretName: tls-secret
  rules:
  - host: mysite.uknorth.cloudapp.azure.com
    http:
      paths:
      - backend:
          serviceName: service-ui
          servicePort: 8080
        path: /
      - backend:
          serviceName: service-api
          servicePort: 8999
        path: /api
</code></pre>

<p>Any guidance appreciated.</p>

Confounder
<p>So let's assume the SSL part is ok (<a href="https://docs.cert-manager.io/en/latest/tasks/issuing-certificates/ingress-shim.html" rel="nofollow noreferrer">link</a>) since you can reach the nginx ingress controller.</p>

<p>Your rewrite annotation is not necessary for what you need. Take a look at these rules:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: myrule
  namespace: mynamespace
  annotations:
    kubernetes.io/ingress.class: nginx
    certmanager.k8s.io/cluster-issuer: letsencrypt-staging
spec:
  tls:
  - hosts:
    - mysite.uknorth.cloudapp.azure.com
    secretName: tls-secret
  rules:
  - host: mysite.uknorth.cloudapp.azure.com
    http:
      paths:
      - backend:
          serviceName: service-ui
          servicePort: 8080
        path: /
      - backend:
          serviceName: service-api
          servicePort: 8999
        path: /api
</code></pre>

<p>Whatever you send to <code>/api/.*</code> will be redirected to service-api. And whatever you send to <code>/</code> will be send to service-ui.</p>
