Gateway & Deployment
YARP reverse proxy gateway, module system, IIS deployment, and Kestrel configuration.
Current backend code is modular-monolith ready and has explicit server roles. Gateway mode is an explicit MODULE_NAME=Gateway role with YARP routes from ServiceDiscovery. True independently deployed microservices are still partial because distributed event delivery is not implemented yet.
YARP Gateway
YARP is registered only when Architecture:Mode=Microservice, MODULE_NAME=Gateway, and ServiceDiscovery has services. Gateway exposes no business controllers; it proxies to configured backend roles.
{
"Architecture": { "Mode": "Microservice" },
"ServiceDiscovery": {
"Services": {
"Identity": "http://localhost:5001",
"Entitlements": "http://localhost:5004",
"Compliance": "http://localhost:5005",
"Plugins": "http://localhost:5006",
"Marketplace": "http://localhost:5007"
}
}
}Module System
MODULE_NAME now represents a server role, not always a pure module. Empty MODULE_NAME loads the full modular monolith. Identity/Auth are composite roles that load Identity plus Entitlements for signup. Gateway loads no business modules.
var rawModuleName = Environment.GetEnvironmentVariable("MODULE_NAME") ?? "";
var moduleName = new DynamicModuleName(rawModuleName, builder.Configuration);
var isMonolith = string.IsNullOrEmpty(rawModuleName);
// Empty MODULE_NAME loads all modules.
// MODULE_NAME=Identity or Auth is a server role; it may load Identity + Entitlements services.
// MODULE_NAME=Gateway loads no business modules and is YARP-only.
if (isMonolith || moduleName.Equals("Identity", StringComparison.OrdinalIgnoreCase))
{
builder.Services.AddIdentityModule(builder.Configuration, builder.Environment);
}
if (isMonolith || moduleName.Equals("Entitlements", StringComparison.OrdinalIgnoreCase))
{
builder.Services.AddEntitlementsModule(builder.Configuration);
}Deployment Modes
Monolith Mode
- MODULE_NAME is empty (all modules in one process)
- Single database connection string
- No YARP gateway needed
- Simpler deployment (1 process)
- Shared appsettings.json
- In-process mediator/domain event handlers
Gateway Architecture & Service Routing
- MODULE_NAME=Identity/Auth is a composed server role, not a pure microservice
- Per-module database
- YARP gateway routes to each service
- Independent scaling per module
- Per-service configuration
- True distributed service-to-service flow is fully supported via the RabbitMQ event bus and MassTransit
IIS Deployment
1. Publish the Application
Run dotnet publish to create the deployment package with all dependencies.2. Configure IIS Site
Create an IIS website pointing to the publish output directory.3. Set Environment Variables
Configure MODULE_NAME and connection strings in the IIS application settings.4. Configure App Pool
Set the application pool to 'No Managed Code' for ASP.NET Core out-of-process hosting.
Kestrel Configuration
{
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://0.0.0.0:7001",
"Certificate": {
"Path": "/certs/scripe.pfx",
"Password": "cert-password"
}
},
"Http": {
"Url": "http://0.0.0.0:5001"
}
},
"Limits": {
"MaxConcurrentConnections": 100,
"MaxRequestBodySize": 10485760,
"RequestHeadersTimeout": "00:00:30"
}
}
}