i have a problem with ASP.Net Core and kube.netes ingress. I have 2 microservices a frontend and backend and With frontend i can see the website but all the wwwroot content is unavailable.
if i go to test.local/webui there is no CSS applied and dev tool outputs 404 for css file and when i hover over the css file it says it is looking at test.local/css/style.css instead of test.local/webui/css/style.css When i manualy go to test.local/webui/css/style.css css file is there.
ingressrule:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test
namespace: test
spec:
ingressClassName: nginx
rules:
- host: "test.local"
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: api
port:
number: 80
- path: /webui
pathType: Prefix
backend:
service:
name: webui
port:
number: 80
startup.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace rmn.WebUI
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UsePathBase("/webui");
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});
}
}
}
i have also tried with different rewrite annotations.
Try something like this
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: cafe-ingress
annotations:
kubernetes.io/ingress.class: "nsx"
ncp/use-regex: "True"
#/tea/cup will be rewritten to /cup before sending request to endpoint
ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: cafe.example.com
http:
paths:
- path: /tea/(.*)
backend:
serviceName: tea-svc
servicePort: 80
- path: /coffee/(.*)
backend:
serviceName: coffee-svc
servicePort: 80
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.