Ionic web app pages not opening with Ingress Controller

7/9/2020

I have Ionic 5.0 Web App running on by Google K8s cluster. I am using Nginx Ingress Controller. Following ingress resource is configured for it to make it accessible:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: gateway-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/use-regex: true
spec:
  rules:
    - http:
        paths:
          - path: /webapp/(/|$)(.*)
            backend:
              serviceName: webapp-frontend
              servicePort: 80

I am able to access the application using the following url:

I am not getting what is wrong with the configuration here. Please help.

####EDIT####

My web application is deployed on pod and have following URL and this is exposed through service 'webapp-frontend':

What i want is when user hit the url on browser following should happen:

-- Prerak Tiwari
angular
ionic-framework
kubernetes
kubernetes-ingress
nginx-ingress

1 Answer

7/9/2020

There are some thing you should look at:

  • NetworkPolicy in the extensions/v1beta1 API version is no longer served from Kubernetes version 1.16. You should use networking.k8s.io/v1beta1 instead.

  • You are using the rewrite annotation and basing on your config it should:

http://1.2.3.4/webapp rewrite to http://1.2.3.4/

http://1.2.3.4/webapp/ rewrite to http://1.2.3.4/

http://1.2.3.4/webapp/login rewrite to http://1.2.3.4/login

You need to make sure that your Ingress is hitting the right URL. The config itself looks fine. The error might be in the logic behind the rewrite that you would like to implement. Refer to the linked documentation if needed. If it is still not working as intended, than please edit your question and provide more details (what should be rewrited where, etc).

This should address your issue from the Kuberentes side. Please let me know if that helped.

-- WytrzymaƂy Wiktor
Source: StackOverflow