<p>I'm new to Kubernetes. I'm using GKE managed service for K8S. There are 2 Deployments nginx, httpd, and created NodePort services for those 2 deploys.</p>
<p>I'm trying to create ingress rule for the services. The nginx ingress controller is installed through helm. I have a domain from freenom and set the Google cloud DNS to use the Static public IP. When I try to hit the ingress URL (domain/nginx), it's giving:</p>
<blockquote>
<p>&quot;default backend - 404&quot;</p>
</blockquote>
<hr />
<p><strong>Deployment:</strong></p>
<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx
  labels:
    name: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx
  replicas: 1
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: httpd
  labels:
    name: httpd
spec:
  selector:
    matchLabels:
      app: httpd
  template:
    metadata:
      labels:
        app: httpd
    spec:
      containers:
        - name: httpd
          image: httpd
  replicas: 1
</code></pre>
<p><strong>Services:</strong></p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  labels:
    name: nginx
  name: nginx-service
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx
  type: NodePort
</code></pre>
<p>Same like for httpd service</p>
<p><strong>Ingress:</strong></p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: test
  annotations:
    kubernetes.io/ingress.global-static-ip-name: testingk8s
spec:
  rules:
    - host: xyz.tk
      http: 
        paths:
          - path: /nginx
            backend:
              serviceName: nginx-service
              servicePort: 80
          - path: /httpd
            backend:
              serviceName: httpd-service
              servicePort: 80
</code></pre>
<p><strong>Ingress describe:</strong></p>
<pre><code>Default backend:  default-http-backend:80 (10.48.0.7:8080)
Rules:
  Host           Path  Backends
  ----           ----  --------
  xyz.tk
                 /nginx   nginx-service:80 (10.48.0.25:80)
                 /httpd   httpd-service:80 (10.48.0.26:80)
Annotations:     ingress.kubernetes.io/backends:
                   {&quot;k8s-be-30916--413d33a91e61ca5d&quot;:&quot;HEALTHY&quot;,&quot;k8s-be-31376--413d33a91e61ca5d&quot;:&quot;HEALTHY&quot;,&quot;k8s-be-32702--413d33a91e61ca5d&quot;:&quot;HEALTHY&quot;}

</code></pre>
<p>Ingress Controller Pod Logs:</p>
<pre><code>I0812 09:38:34.405188       6 event.go:278] Event(v1.ObjectReference{Kind:&quot;Ingress&quot;, Namespace:&quot;nginx&quot;, Name:&quot;test&quot;, UID:&quot;61991dbd-a361-47d2-88cc-548a7c43e743&quot;, APIVersion:&quot;networking.k8s.io/v1beta1&quot;, ResourceVersion:&quot;316030&quot;, FieldPath:&quot;&quot;}): type: 'Normal' reason: 'CREATE' Ingress nginx/test
I0812 09:38:34.405815       6 controller.go:139] Configuration changes detected, backend reload required.
I0812 09:38:34.532163       6 controller.go:155] Backend successfully reloaded.
I0812 09:38:41.369315       6 status.go:275] updating Ingress nginx/test status from [] to [{35.192.136.218 }]
I0812 09:38:41.374080       6 event.go:278] Event(v1.ObjectReference{Kind:&quot;Ingress&quot;, Namespace:&quot;nginx&quot;, Name:&quot;test&quot;, UID:&quot;61991dbd-a361-47d2-88cc-548a7c43e743&quot;, APIVersion:&quot;networking.k8s.io/v1beta1&quot;, ResourceVersion:&quot;316057&quot;, FieldPath:&quot;&quot;}): type: 'Normal' reason: 'UPDATE' Ingress nginx/test

</code></pre>

<p>Add annotations <code>kubernetes.io/ingress.class: nginx</code> and <code>nginx.ingress.kubernetes.io/rewrite-target: /</code>. So the ingress looks like below</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: test
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - host: xyz.tk
      http: 
        paths:
          - path: /nginx
            backend:
              serviceName: nginx-service
              servicePort: 80
          - path: /httpd
            backend:
              serviceName: httpd-service
              servicePort: 80
</code></pre>
