I'm sorry if I might be using a different term, but I don't really know what terms should I use, that's why I'm having a hard time to search this over search engines.
Anyway, I have an ASP.NET Core 8.0 Web API and I used a Route
attribute on the HTTP GET
method of my FileController
. The URL format is something like this when debugging on local:
http://localhost:8080/api/file/{appId}/{key}
It is working properly.
But through the Kubernetes ingress, I'm getting a 404 error if I try to access it with this url:
https://example.com/serviceapi/myservice/api/file/{appId}/{key}
All the other Web API endpoints are working properly - just not this one.
Here's the YAML of the ingress:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myservice.ingress
namespace: myservice
annotations:
nginx.org/mergeable-ingress-type: "minion"
nginx.org/rewrites: "serviceName=myservice-webapi rewrite=/"
spec:
ingressClassName: nginx
rules:
- host: example.com
http:
paths:
- path: /serviceapi/myservice/
pathType: Prefix
backend:
service:
name: myservice-webapi
port:
number: 80
When we use nginx.org
, we can use ImplementationSpecific
for url rewrite.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myservice-ingress
namespace: myservice
annotations:
nginx.org/mergeable-ingress-type: "minion"
nginx.org/rewrites: "serviceName=myservice-webapi rewrite=/$2 break"
spec:
ingressClassName: nginx
rules:
- host: example.com
http:
paths:
- path: /serviceapi/myservice(/|/.*)
pathType: ImplementationSpecific
backend:
service:
name: myservice-webapi
port:
number: 80