The taboo of failure in IT projects
December 13, 2021AWS Amplify, different build settings for different branches.
August 20, 2022AWS ALB Health Check for multiples app or services on NGINX
There are many reasons to deploy multiple apps or services on a NGINX AWS EC2 instance, from cost savings to redundancy. In our case, we have an Application Load Balancer handling all requests to a Target Group (or Server Farm). However, in those cases is not just straightforward to set up the targets health check.
This post presents a solution to that scenario.
Case
Our EC2 Instance has a default website on port 80 and 2 or more apps on port 80 but with different host headers (ie: aka.mydomain.com, afa.mydomain.com, etc), so when it is time to set up the Target Group Health Check we need a solution to how to monitor each service (or app) instead of the default NGINX site.
Solution
We ended up changing our default NGIX website (etc/nginx/sites-available/default) by including the following segment:
location /aka {
proxy_set_header Host aka.mydomain.com;
proxy_pass http://127.0.0.1/health;
}
location /afa {
proxy_set_header Host afa.mydomain.com;
proxy_pass http://127.0.0.1/health;
}
Therefore, on each Target Group, we can use on the path of the Health Check “/aka” and in the other Target Group “/afa”. We are doing an NGINX redirect and adding the host header, the health route is a health check page on all our applications that returns 200 and some details of the status of our apps and services.
Now, Our EC2 instance running multiple NGINX apps or services can be a target on both Target Groups and the health check will do its job if one of the services is down sending requests to any other available targets.
Do you have an idea and want to make a prototype to see if it is functional or sustainable over time? Then, 23blocks is the best solution that you will find to carry out this development with less effort and investment.
Each of our blocks is a combination of Software, Infrastructure, and Services, which are available as API Microservices. According to industry standards, these are hosted in a highly available cloud, ready for production and use.
Making the decision to start a software project can be complicated and intimidating. So, contact us at info@23blocks.com to receive free assistance from our software experts and get started on your idea.
There is a better way to build apps and platforms —the #23blocksway.