Deploying .Net Core WebApi Docker Image to Azure Kubernetes Service using Nginx Ingress Controller
Looks like you messed up your ingress object. I assume you want to rewrite the /demo
path to /
so that paths like: /demo/foo/bar
are rewritten to /foo/bar
.
Here is the rewrite explained.
Here is the example:
kind: IngressapiVersion: networking.k8s.io/v1beta1metadata: name: econnect-ingress namespace: development annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/rewrite-target: /$2 nginx.ingress.kubernetes.io/ssl-redirect: 'false'spec: rules: - http: paths: - path: /demo(/|$)(.*) pathType: Prefix backend: serviceName: weather-forecast-webapi-service-clusterip servicePort: 80
Notice that all I changed is path and rewtire-tager group number. In /demo(/|$)(.*)
the brackets ()
create a group that is referenced in rewrite-target: /$2
. The $1 is referencing the first group: / or end of string
, and the second group is everything after it; so you copy everything after the /demo/
and make it a new path.