【发布时间】:2021-11-01 06:20:20
【问题描述】:
我想使用 Yarp 实现反向代理。 Api 已启动并正在运行,因为我可以向它发送请求。但是,每当我通过代理尝试相同的请求时,我都会收到错误 502 Bad gateway
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddReverseProxy()
.LoadFromConfig(Configuration.GetSection("ReverseProxy"));
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
// Register the reverse proxy routes
app.UseEndpoints(endpoints =>
{
endpoints.MapReverseProxy();
});
}
应用设置
"ReverseProxy": {
"Routes": {
"route1": {
"ClusterId": "cluster1",
"Match": {
//"Methods": [ "GET", "POST", "PUT", "HEAD", "OPTIONS", "DELETE" ],
"Path": "{**catch-all}"
}
}
},
"Clusters": {
"cluster1": {
"Destinations": {
"cluster1/destination1": {
"Address": "https://localhost:44339/"
}
}
}
}
}
每当我通过代理发送请求时,我都会收到响应 502 bad gateway
【问题讨论】:
标签: c# asp.net-core asp.net-core-3.1 yarp