This Windows service and has some web api controllers. The IIS which we want to use as reverse proxy already has some services hosted on it.
Below is the Program class for windows service. Is it possible to use IIS as reverse proxy where IIS takes request and pass on to windows service which is running on kestrel server.
Any help is appreciated. Thanks.
public class Program
{
private static async Task Main(string[] args)
{
var isService = !(Debugger.IsAttached || args.Contains("--console"));
var builder = CreateWebHostBuilder(args.Where(arg => arg != "--console").ToArray());
var host = builder.Build();
if (isService)
{
host.RunAsService();
}
else
{
host.Run();
}
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel((context, serverOptions) =>
{
serverOptions.Configure(context.Configuration.GetSection("Kestrel"))
.Endpoint("HTTPS", listenOptions =>
{
listenOptions.HttpsOptions.SslProtocols = SslProtocols.Tls12;
});
})
.UseIISIntegration()
.UseUrls("https://MyMachineName");
}
BElow is kestrel configuration is appsettings.json
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://localhost:6000"
},
"Https": {
"Url": "https://*:6001"
}
},
"Certificates": {
"Default": {
"Subject": "certificatename",
"Store": "Root",
"Location": "LocalMachine",
"AllowInvalid": true
}
}
}