How To Configure Aws Elastic Load Balancer's Heath Check For Node.js
I'm new to Node.js, my question could be stupid to someone, please forgive me for this. In the past, I have Apache installed on an EC2 instance. I created ping.html inside this di
Solution 1:
It depends on what you want to check and what you are using with node.js. If you just wanted the check to make sure that the node.js server is running, you could simply add this to the HTTP server:
var server = http.createServer(function(request, response) {
if (request.url === '/ping.html' && request.method ==='GET') {
//AWS ELB pings this URL to make sure the instance is running//smoothly
response.writeHead(200, {
'Content-Type': 'text/plain',
'Content-Length': 2
});
response.write('OK');
response.end();
}
//Do the rest of your web server here
});
server.listen(8080/* Whatever port */);
If you are using something with node that servers content like express.js then you could just make the ELB check the content of a page that express.js serves.
Post a Comment for "How To Configure Aws Elastic Load Balancer's Heath Check For Node.js"