I have an Nginx ingress controller virtualServre manifest as
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: tea-vs
spec:
host: apps.example.com
routes:
- path: /
pathType: Prefix
rewrite:
path: /tea/
route:
path: /tea(.*)
pathType: Prefix
service:
name: tea-svc
port:
number: 80
My app serves at /
. When I type apps.example.com
, it swagger UI loads and displays URL as apps.example.com/index.html
My requirement is:
-
if user enters
apps.example.com/tea
, the swagger UI should load even its serving at root. -
My tea-svc should receive a request for
apps.example.com
but NOTapps.example.com/tea
-
Users still see the URL as
apps.example.com/tea/index.html
(orapps.example.com/index.html
) -
I prefer not to use Nginx
Kind: Ingress
My dotnet code is below, and I don’t want to touch it as it’s already working in PROD. I am doing this as part of the migration to Nginx ingress controller and wanted to migrate to path based routing from the host based which I feel will bring some flexibility
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "V1");
c.RoutePrefix = string.Empty;
});
app.UseRouting();
Struggling with this as I always get 404, when I attempt to do any path-based routing
Any help on this is highly appreciated