Search code examples
.netamazon-web-serviceshttpssubdomaingodaddy-api

Hosting .Net WebAPI and WebApp on same EC2 instance


I have an AWS account and i am using ec2 windows instance under free tier to test an application. I created two website(one for API and other for website) under IIS on that instance and both are running perfectly. For eg: API: http://x.y.z.w:9999 Website: http://x.y.z.w:9090

Now I have a requirement to make it https, both website and API, I am able to do it for website as I have a valid domain, let say example.com with https(from GoDaddy) with me. But what about APIs? How can I make it api.example.com with https and point to my api website. ?

Do I need to buy a separate ec2 instance to host api or is there a way to host it on same ec2 instance?


Solution

  • You do not need a new instance. Simply add a load balancer, install your certificate on it (you can also use Amazon Certificate Manager), define some rules for your website and API, and register your instance to it. This way, you do not need to install your certificate on your IIS. You can read more here.