I'm having trouble hosting multiple websites on different sub-domains using Service Fabric and OWIN.
Let's say I have four HTTP(S) servers on my Service Fabric cloud. Each of them are running on a different port. So at some point of their initialization, they will respectively call:
Microsoft.Owin.Hosting.WebApp.Start("http://+:80/", UnsecureStartup);
Microsoft.Owin.Hosting.WebApp.Start("https://+:443/", MainStartup);
Microsoft.Owin.Hosting.WebApp.Start("https://+:4431/", ApiStartup);
Microsoft.Owin.Hosting.WebApp.Start("https://+:4432/", ExtrasStartup);
This all works fine. All requests are successfully fulfilled. All four ports serve the startups they've been assigned in their respective stateless services, and the HTTPS ones make use of the same certificate as set from ServiceManifest.xml
in proper Service Fabric fashion. Here's a similar single-server setup.
We always planned to use sub-domains instead of different ports. Now we have our domain and we're trying to do the following:
Microsoft.Owin.Hosting.WebApp.Start("http://example.com:80/", UnsecureStartup);
Microsoft.Owin.Hosting.WebApp.Start("https://example.com:443/", MainStartup);
Microsoft.Owin.Hosting.WebApp.Start("https://api.example.com:443/", ApiStartup);
Microsoft.Owin.Hosting.WebApp.Start("https://extras.example.com:443/", ExtrasStartup);
The code above does run. All four stateless services start and go green in Service Fabric Explorer. Yet, every single request (both to http:80
and to https:445
) is met with the same response:
Service Unavailable
HTTP Error 503. The service is unavailable.
Why does Service Fabric allow us to have multiple Owin servers, even on the same port, if it's not possible for me to select one based on hostname? Does anyone have any idea of how we can make this work?
Any help is greatly appreciated.