DEV Community

Ivan
Ivan

Posted on

Build a Microservice to Monitor SSL

Monitor SSL Certificates (and Get Alerts Automatically)

If you manage websites or deal with infrastructure, you know that forgetting to renew an SSL certificate can cause serious trouble: downtime, security warnings, and loss of trust.

To solve this, I built a lightweight microservice in Node.js that checks the SSL validity of any domain — and can be fully automated using n8n.


What is this microservice?

It’s a simple HTTP API with one endpoint:

GET /check?host=yourdomain.com
Enter fullscreen mode Exit fullscreen mode

It returns the SSL certificate status:

{
  "domain": "yourdomain.com",
  "valid": true,
  "expires_on": "2025-07-10T12:00:00.000Z",
  "days_remaining": 25
}
Enter fullscreen mode Exit fullscreen mode

If the domain is invalid or unreachable:

{
  "domain": "invalidsite.com",
  "valid": false,
  "error": "getaddrinfo ENOTFOUND invalidsite.com"
}
Enter fullscreen mode Exit fullscreen mode

It uses only native Node.js tls and the express library. Fast and efficient.


How to use it

Clone the repo, install dependencies, and run:

npm install
npm start
Enter fullscreen mode Exit fullscreen mode

Then visit:

http://localhost:2999/check?host=yourdomain.com
Enter fullscreen mode Exit fullscreen mode

Automating with n8n

The real power comes with automation using n8n — a visual workflow automation tool.

With it, you can:

  • Run scheduled checks (every 12h, 20min, etc.)
  • Monitor multiple domains in batch
  • Send alerts via email or Slack when:

    • The SSL is about to expire
    • The domain is down
    • There's a DNS or connection error
  • Log all responses into a MySQL database (for reporting or analytics)

💡 I included a pre-configured .json workflow you can import into n8n and customize.


Real-world scenario

Say you manage 35 websites and subdomains.

With this microservice + n8n, you can:

  • Monitor all domains on autopilot
  • Get alerts before users report issues
  • Stay in control without spreadsheets or expensive monitoring services

Requirements

  • Node.js 18+
  • PM2 (optional, for running it as a service)
  • n8n (optional but highly recommended)

Project structure

.
├── server.js              ← main microservice code
├── package.json
├── README.md
├── site_ssl_monitor.json  ← n8n workflow
Enter fullscreen mode Exit fullscreen mode

Final thoughts

This microservice solves a common pain for developers, sysadmins, and IT teams — in a simple, free, and self-hosted way.

If you enjoy automation, security, and full control over your tools, this is for you.

➡️ GitHub repo

If you find this helpful, leave a comment or follow me for more smart tools like this.

Top comments (0)