How to enable SSL certificates (including HTTPS redirection & HSTS) for HestiaCP subdomains in batches?

Have you ever encountered such a situation? HestiaCP The server and subdomains have been created, but I find that I need to manually apply for and configure SSL certificates one by one? 🤯 That’s too much torture!

Don't worry, I'll teach you a trick today. One-click batch activation of SSL, including not only Let's Encrypt Certificates, and directly help you enable HTTPS automatic redirectionHSTS (HTTP Strict Transport Security).

🔥 Why enable SSL in bulk?

You might be thinking: "Can't I just click them manually?" Of course, but if you have Dozens or hundreds of subdomains, manual operation is undoubtedly self-abuse!

Batch processing has the following benefits:
save time: One-click execution, no need to click manually.
Avoid omissions: Reduce human errors and ensure all subdomains are secure.
Force HTTPS: Automatically redirect HTTP -> HTTPS, improve SEO score.
HSTS security hardening: Prevent man-in-the-middle attacks and make the site more secure.

💡 Specific operation steps

Next, we use the command line tool that comes with HestiaCP to write a simple Shell script, easily done All subdomains SSL configuration for .

How to enable SSL certificates (including HTTPS redirection & HSTS) for HestiaCP subdomains in batches?

📝 Step 1: Get a list of subdomains

Assume your primary domain is chenweiliang.com, you have added multiple subdomains, for example:

  • www.chenweiliang.com/en
  • ru.chenweiliang.com
  • la.chenweiliang.com
  • lv.chenweiliang.com

In the script, we only need to maintain a list of subdomain prefixes, for example:

SUBDOMAINS="en ru la lv"

Later we will loop through these subdomains and apply for SSL certificates one by one.


📜 Step 2: Write a script to enable SSL certificates in batches

HestiaCP provides Command line tools, we can complete SSL related operations with the following three commands:

  • v-add-letsencrypt-domain → Apply for SSL certificate
  • v-add-web-domain-ssl-force → Enforce HTTPS
  • v-add-web-domain-ssl-hsts → Enable HSTS

The complete script is as follows (copy and execute directly) :

#!/bin/bash

# HestiaCP 用户名
USER="youruser"
# 你的主域名
DOMAIN="chenweiliang.com"
# 需要启用 SSL 的子域名前缀
SUBDOMAINS="en ru la lv"
# 遍历每个子域名,依次开启 SSL
for SUB in $SUBDOMAINS
do
    FULL_DOMAIN="$SUB.$DOMAIN"
    echo "🚀 在启用 $FULL_DOMAIN 的 SSL 配置..."

    # 申请 Let's Encrypt 证书
    v-add-letsencrypt-domain $USER $FULL_DOMAIN
    if [ $? -ne 0 ]; then
        echo "❌ 错误:获取 $FULL_DOMAIN SSL 证书失败(可能触发 Let's Encrypt 429 限流),请稍后重试。"
        continue
    fi

    # 强制 HTTPS 重定向
    v-add-web-domain-ssl-force $USER $FULL_DOMAIN

    # 启用 HSTS(HTTP 严格传输安全)
    v-add-web-domain-ssl-hsts $USER $FULL_DOMAIN

    echo "✅ $FULL_DOMAIN SSL 配置完成!"
done
echo "🎉 所有子域名 SSL 配置操作结束!"

🚀 Step 3: Execute the script

Now that the script is written, let’s run it!

1️⃣ Save the script as enable_ssl.sh
2️⃣ Grant execution permissions :

chmod +x enable_ssl.sh

3️⃣ run script :

./enable_ssl.sh

Then you can see SSL certificates for all subdomains Apply and enable automatically!


⚠ Notes

💡 About Let's Encrypt current limiting (429 error)
Let's Encrypt Limit the number of certificate requests per IP within one hourIf you configure too many subdomains at once, you may encounter 429 error.

✅ Click the link below to view the solution ▼

  • Apply in batches, only running a few subdomains at a time.
  • Using a different ACME endpoint(For example, Cloudflare API application certificate).
  • Wait 1 hour and try again.

💡 Check if HestiaCP has correctly installed the SSL certificate
If you find SSL configuration failed, you can check it manually:

v-list-web-domain $USER yoursubdomain.chenweiliang.com

Look at SSL Is the field yesIf not, you need to enable it manually.


🎯 Conclusion

It is not difficult to activate SSL certificates in batches. The key is to use the right method. HestiaCP command line + Shell script,you can One-click HTTPS configuration for all subdomains, both efficient and safe.

💡 This will not only save you a ton of time, but will also improve your SEO score and website security., why not?

Try it now and add HTTPS protection to your subdomains to make them more secure and professional! 🚀

Comment

Your email address will not be published. Required fields * Callout

Scroll to Top