Cannot tunning simple Gateway for 2 microservices in docker. Please help me #1780
-
Hello, i think this is very simple issue, but i am cannot solve themself. Please read my description. I am have
namespace Payments.Controllers
{
[ApiController]
[Route("[controller]")]
public class PaymentController : ControllerBase
{
private readonly ILogger<PaymentController> _logger;
public PaymentController(ILogger<PaymentController> logger)
{
_logger = logger;
}
[HttpGet]
public string Get()
{
return "PaymentService";
}
}
}
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
using Microsoft.AspNetCore.Mvc;
namespace Clients.Controllers
{
[ApiController]
[Route("[controller]")]
public class ClientController : ControllerBase
{
private readonly ILogger<ClientController> _logger;
public ClientController(ILogger<ClientController> logger)
{
_logger = logger;
}
[HttpGet]
public string Get()
{
return "ClientService";
}
}
}
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
var app = builder.Build();
app.MapReverseProxy();
app.Run(); {
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ReverseProxy": {
"Routes": {
"payments": {
"ClusterId": "payments",
"Match": {
"Path": "/payments/{**catch-all}"
}
},
"clients": {
"ClusterId": "clients",
"Match": {
"Path": "/clients/{**catch-all}"
}
}
},
"Clusters": {
"payments": {
"Destinations": {
"destination1": {
"Address": "https://payment/"
}
}
},
"clients": {
"Destinations": {
"destination1": {
"Address": "https://client/"
}
}
}
}
}
}
version: '3.4'
services:
payments:
image: ${DOCKER_REGISTRY-}payments
hostname: payment
container_name: Payment
ports:
- 51001:443
build:
context: .
dockerfile: Payments/Dockerfile
clients:
image: ${DOCKER_REGISTRY-}clients
hostname: client
container_name: Client
ports:
- 51002:443
build:
context: .
dockerfile: Clients/Dockerfile
gateway:
image: ${DOCKER_REGISTRY-}gateway
hostname: gateway
container_name: Gateway
ports:
- 51000:443
build:
context: .
dockerfile: Gateway/Dockerfile When i am running in postman GET https://localhost:51000/payments info: Yarp.ReverseProxy.Forwarder.HttpForwarder[48]
Request: An error was encountered before receiving a response.
System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch, RemoteCertificateChainErrors
at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception)
at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions)
at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)
--- End of inner exception stack trace --- In attach i am put full solution. Please help me with
|
Beta Was this translation helpful? Give feedback.
Answered by
samsp-msft
Jun 27, 2022
Replies: 2 comments 3 replies
-
Your routes map to https://payment, but without a port number. Your docker configuration has them on ports 51001, so its probably not reaching the destination that it thinks it is, hence the TLS error that you are seeing. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
karelz
-
Hello, thank you for your help. I am changes "Clusters": {
"payments": {
"Destinations": {
"destination1": {
"Address": "https://payment:51001/"
}
}
},
"clients": {
"Destinations": {
"destination1": {
"Address": "https://client:51002/"
}
}
}
} But now get info: Yarp.ReverseProxy.Forwarder.HttpForwarder[9]
Proxying to https://payment:51001/payments HTTP/2 RequestVersionOrLower no-streaming
Yarp.ReverseProxy.Forwarder.HttpForwarder: Information: Proxying to https://payment:51001/payments HTTP/2 RequestVersionOrLower no-streaming
info: Yarp.ReverseProxy.Forwarder.HttpForwarder[48]
Request: An error was encountered before receiving a response.
System.Net.Http.HttpRequestException: Connection refused (payment:51001)
---> System.Net.Sockets.SocketException (111): Connection refused
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your routes map to https://payment, but without a port number. Your docker configuration has them on ports 51001, so its probably not reaching the destination that it thinks it is, hence the TLS error that you are seeing.