0

I am using Azure Cloud Service and it packs two Roles: ASP.net MVC and ASP.net Web API projects. My MVC project uses ports 80 (for standard http protocol) and 443 (for https). And my API project is using 8080 (http) and 8443 (https).

What I would like to do is to assign 8080,8443 and 443 to my API project, and to my MVC project keep 80, and assign some other port for https (for example 8444).

What I did is edited Endpoints under Roles' properties (as described above), and it worked, kind of.

What is troubling me still is that when in a browser I enter https://mypage.com I am taken to my API page and not my MVC web page. So how can I fix this (meaning that I want both my MVC and API projects to be accessible trough port 443) Could having https://api.mypage.com for my API project fix this? If yes how can I configure my DNS (which is on GoDaddy) and Cloud Service to support https://api.mypage.com?

hyperN
  • 2,674
  • 9
  • 54
  • 92
  • Based on `What I would like to do is to assign 8080,8443 and 443 to my API project`, aren't you assigning port 443 to your API project? – Gaurav Mantri Jan 30 '17 at 18:41
  • Yes, I am, but the problem is, when I do this and in browser type https://mypage.com I am taken to API page, and I would like to be taken to MVC project – hyperN Jan 30 '17 at 18:46
  • In this case, shouldn't you be assigning port 443 (default for HTTPS) to your MVC project? – Gaurav Mantri Jan 30 '17 at 18:48
  • Yes, I should, but, is there way for my API project to be using port 443 (for example by having api.mypage.com) and at the same time when user enters https:// mypage.com he is sent to MVC project ? – hyperN Jan 30 '17 at 18:52
  • Aah...I see what you're saying (I think :)) - You want to access your API on port 443 as well. If I am not mistaken, you would need to deploy your API into a separate cloud project and then map that cloud projects domain to api.mypage.com. – Gaurav Mantri Jan 30 '17 at 18:58
  • Yeah, please accept my apologies for bad explanation and thanks for your answer, I was hoping for different one, but if that's the case, nothing can be done about that :) – hyperN Jan 30 '17 at 19:15
  • Application Gateway can do the routing for you -- https://azure.microsoft.com/en-us/services/application-gateway/ You'll have 80 and 443 for the outside world and then map that based on subdomains on custom ports back to your WebRoles. (`example.com` -> 8080 and 8443 and `api.example.com` -> 8081 and 8444 – evilSnobu Jan 30 '17 at 21:46

1 Answers1

0

Application Gateway can do the routing for you -

You'll have 80 and 443/TCP for the outside world and then map that based on URL/subdomain to custom ports back to your WebRoles.

E.g.

    example.com ---> 8080/TCP and 8443/TCP
api.example.com ---> 8081/TCP and 8444/TCP

More on that here: https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-multi-site-overview

A pair of varnish or nginx boxes will pretty much have the same result with the added benefit of caching things along the way. Downside is that you'll have to do it in IaaS and that's the opposite of an elegant weapon for a more civilized age...

Sample config for varnish: Configure multiple sites with Varnish

EDIT

Actually you COULD do it in PaaS on App Service with Docker containers: https://learn.microsoft.com/en-us/azure/app-service-web/app-service-linux-using-custom-docker-image

You know what, maybe it's time to move those services over to App Service as two different Web Apps, each listening on its own subdomain. If you don't need elevation and you don't do messy things like write to registry you should be fine and you could drop a locomotive-worth of complexity straight away.

It's a crazy time to be alive.

Community
  • 1
  • 1
evilSnobu
  • 24,582
  • 8
  • 41
  • 71