2
votes

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:

  1. Microsoft.Owin.Hosting.WebApp.Start("http://+:80/", UnsecureStartup);
  2. Microsoft.Owin.Hosting.WebApp.Start("https://+:443/", MainStartup);
  3. Microsoft.Owin.Hosting.WebApp.Start("https://+:4431/", ApiStartup);
  4. 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:

  1. Microsoft.Owin.Hosting.WebApp.Start("http://example.com:80/", UnsecureStartup);
  2. Microsoft.Owin.Hosting.WebApp.Start("https://example.com:443/", MainStartup);
  3. Microsoft.Owin.Hosting.WebApp.Start("https://api.example.com:443/", ApiStartup);
  4. 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.

1
Have you looked at this answer? stackoverflow.com/a/38709470/4852187masnider
@masnider It does solve the problem for HTTP, but not for HTTPS, which is a requirement for me. Thanks for that anyway.Ekevoo

1 Answers

1
votes

In my understanding, hostnames does not work very well with SF. You have the following options as I see it:

1) You use different ports on your internal services and put a WAF in front of your SF Cluster and let that one handle SSL offloading, URL routing and NATing to your internal ports. This way you will only need 1 public IP.

2) You add more public IPs and let your public load balancing handle it. You will need 3 IP addresses for this, but since the first 5 IPs are free in azure, this wont cost you anything extra.

You probobly want to go with option 1 as it gives you easier certificate managing, better security and more flexibility but at the cost of $.