Canonical: https://vpsmap.net/en/guides/https-certificates/
Language: en
Updated: 2026-09-26T00:00:00+08:00

Website Setup

# HTTPS Automation and Full Certificate Lifecycle Management: ACME.sh, DNS-01 Wildcard Issuance, and Production Nginx TLS 1.3 Configuration

VPSMap Editorial · Updated 2026-09-26 · 24 min read · [Plain-text version](https://vpsmap.net/guides/https-certificates/index.md)

In modern web architecture, Transport Layer Security (TLS) is more than a compliance requirement: it is fundamental to website speed, SEO ranking, and data integrity. When a site is hosted on an overseas cloud server with premium routing, such as BandwagonHost's CN2 GIA series or DMIT Premium/Pro instances, the inherently high physical round-trip time (RTT) of international transmission makes TLS handshake optimization and highly available certificate rotation particularly important.

Many administrators still maintain certificates with Certbot and HTTP-01 validation. In single-server, low-spec, or complex-network production environments, this approach introduces multiple risks: unnecessary memory overhead from Python and Snap runtimes, the security compromise of exposing port 80 publicly, the lack of flexibility to issue wildcard certificates, and interrupted renewals caused by firewall or CDN blocking.

From a practical modern web-infrastructure perspective, this article systematically examines the pure-Shell automation tool **acme.sh** and **DNS-01 Validation**certificate lifecycle solution, implementing a strong Nginx TLS 1.3 production configuration with Perfect Forward Secrecy (PFS), zero-downtime reloads, and an SSL Labs A+ rating.

## One. Choosing Certificate Automation: Architectural Trade-Offs Between acme.sh and Certbot[#](https://vpsmap.net/en/guides/https-certificates/#section-1)

In cloud server operations, the choice of automation client directly affects resource utilization and system stability.

| Dimension | Certbot (Officially Recommended by EFF) | acme.sh (Lightweight, Zero-Dependency Solution) |
| --- | --- | --- |
| **Underlying Implementation** | Python 3 + Snap Package Manager or System-Level Dependencies | Pure POSIX Shell (Compatible with sh, bash, and dash) |
| **Disk and Memory Usage** | Depends on dozens of Python libraries, with resident and runtime memory usage of 100MB~200MB+ | The Script Is Only a Few Hundred KB, with Negligible Runtime Memory Use (< 10MB) |
| **System Upgrade Risks** | System Upgrades (Such as Debian/Ubuntu Major-Version Changes) Can Easily Cause Python Dependency Conflicts | No External Runtime; Relies on the System's Native `openssl` and `curl`, with exceptional stability |
| **DNS API Support** | requires specific plugin packages, such as `certbot-dns-cloudflare`） | Built-In Native Support for DNS APIs from 150+ Providers Worldwide |
| **Supported Certificate Algorithms** | RSA by Default; Additional Parameters Required to Enable ECC | Native, Comprehensive Dual Support for ECC (ECDSA) and RSA |

When running production workloads on lightweight instances, such as basic BandwagonHost plans or DMIT Starter/Pocket plans with typically around 1GB of memory, resources should be prioritized for Nginx, databases, and core applications. Certbot and its background Snap daemon can cause memory fluctuations when scheduled tasks run, potentially leading the kernel to kill critical processes through OOM (Out Of Memory).

**acme.sh** Its pure-Shell architecture fully decouples it from the application environment. Compact and naturally compatible with Linux scheduling through Cron / Systemd Timers, it is ideal for low-overhead, highly stable operations.

## Two. Validation Mechanisms: Why Production Should Fully Adopt DNS-01[#](https://vpsmap.net/en/guides/https-certificates/#section-2)

The ACME (Automated Certificate Management Environment) protocol primarily provides two methods for validating domain control:

### 1. Limitations of HTTP-01 Validation[#](https://vpsmap.net/en/guides/https-certificates/#section-3)

- **Mandatory Port Binding**: The CA server must access the server's following path over external HTTP (port 80): `/.well-known/acme-challenge/` path. If the production instance has a strict inbound security group, or port 80 is blocked by a reverse proxy, internal-network isolation, or an intermediate security gateway, validation will fail outright.

- **Wildcard Domains Not Supported**: HTTP-01 cannot issue `*.example.com` wildcard certificates. Each newly added subdomain requires another configuration change and separate certificate issuance, increasing operational complexity.

- **Risk of Cross-Border Network Interference**: Let's Encrypt's validation clusters are distributed worldwide. If HTTP requests from overseas nodes encounter temporary routing instability or cross-border gateway resets, certificate rotation can fail.

### 2. Production Advantages of DNS-01 Validation[#](https://vpsmap.net/en/guides/https-certificates/#section-4)

- **Fully Decouple Network Ingress**: The CA does not directly access any port on the VPS. Validation depends only on TXT records on authoritative DNS servers (`_acme-challenge.example.com`）。

- **Native Wildcard Support**: A single certificate can cover the root domain `example.com` and all subdomains `*.example.com`, greatly simplifying deployment of subsystems and microservices architectures.

- **Strong Security and Support for Private-Network Environments**: Even if the cloud server is in a private VPC, has no elastic public IP, or accepts only allowlisted IPs, certificate issuance and renewal can run silently as long as it can send outbound HTTPS requests to the DNS API.

## Three. Prerequisites: System Preparation and Secure Operations Guidelines[#](https://vpsmap.net/en/guides/https-certificates/#section-5)

Before configuring certificates, ensure the host meets standard networking, security, and time-synchronization baselines.

### 1. Instance Access and Operations Security Baseline[#](https://vpsmap.net/en/guides/https-certificates/#section-6)

Providers Differ in Their Underlying Operations Logic:

- **DMIT instance **: system images disable remote root password login by default during initial provisioning and require SSH key authentication. To change the authentication method or manage keys, use the DMIT console's **Access** perform the operation in the panel. Note that after updating the public key, you must reboot the instance (Reboot) through the panel before the new configuration is written to metadata and takes effect. If a firewall misconfiguration blocks the SSH port, you can use the instance panel's **Console** for out-of-band recovery.

- **BandwagonHost instance **: its KiwiVM management console has a dedicated administration password independent of both the client area and the system root password. If the host network is misconfigured or ports are blocked, you can use KiwiVM's **Interactive Console** enter the terminal for offline troubleshooting.

### 2. Synchronize the System Time and Time Zone[#](https://vpsmap.net/en/guides/https-certificates/#section-7)

ACME signature tokens and TLS certificate chains are extremely sensitive to timestamps. If the host system clock drifts by more than a few minutes, ACME handshake signatures may become invalid or OCSP Stapling validation may fail.

Using Ubuntu / Debian as an example, configure system time synchronization:

bash

```
# 安装 chrony 时间同步工具
apt update && apt install -y chrony

# 启动并启用开机自启
systemctl enable --now chronyd

# 验证时间同步状态
chronyc tracking
```

Ensure the local System time offset remains within milliseconds.

### 3. Install Basic Networking and Cryptographic Tools[#](https://vpsmap.net/en/guides/https-certificates/#section-8)

Ensure that the system has the POSIX tools required to run acme.sh:

bash

```
apt install -y curl socat openssl cron
```

## Four. Deploy acme.sh and Automate Certificate Issuance with the Cloudflare DNS API[#](https://vpsmap.net/en/guides/https-certificates/#section-9)

### Step 1: Install acme.sh[#](https://vpsmap.net/en/guides/https-certificates/#section-10)

Run the official installation script as root. Supply a valid email address to receive official Let's Encrypt alerts about major certificate issues, such as API failures or CA policy changes:

bash

```
curl https://get.acme.sh | sh -s email=admin@example.com
```

The script automatically performs the following actions:

1. Install the core script in `/root/.acme.sh/`；

1. In `/root/.bashrc` create an alias in `acme.sh`；

1. Automatically detects the system's Crontab and adds a daily scheduled task to check for updates.

Apply the Changes to the Current Shell Environment:

bash

```
source ~/.bashrc
```

### Step 2: Change the Default Certificate Authority (CA)[#](https://vpsmap.net/en/guides/https-certificates/#section-11)

acme.sh currently defaults to ZeroSSL as its upstream CA. For compatibility and issuance speed, explicitly switch to Let's Encrypt, or retain ZeroSSL if needed:

bash

```
acme.sh --set-default-ca --server letsencrypt
```

### Step 3: Configure a Cloudflare API Token (Principle of Least Privilege)[#](https://vpsmap.net/en/guides/https-certificates/#section-12)

Never use an overly permissive Global API Key. Create a dedicated API Token in the Cloudflare dashboard following the principle of least privilege:

1. Log into Cloudflare and go to **My Profile -> API Tokens**, click **Create Token**；

1. Select **Create Custom Token**；

1. **Token name**: Can be named `acme-dns-operator`；

1. **Permissions**：

- `Zone` - `DNS` - `Edit`

- `Zone` - `Zone` - `Read`

1. **Zone Resources**：

- `Include` - `Specific zone` - Select your target domain;

1. Create and save the Token string.

Export temporary environment variables in the cloud server terminal. After the first successful issuance, acme.sh automatically saves the encrypted credentials in sanitized form to `~/.acme.sh/account.conf` , and subsequent scheduled tasks will reuse it automatically, without needing to `.bashrc` hardcoded permanently in it):

bash

```
export CF_Token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export CF_Account_ID="yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
```

### Step 4: Issue an ECC Wildcard Certificate[#](https://vpsmap.net/en/guides/https-certificates/#section-13)

It is recommended to adopt modern Elliptic Curve Cryptography (ECC) throughout, using `P-256` algorithm, which significantly outperforms traditional RSA 2048/4096 in handshake efficiency, computing resource consumption, and transmission size.

Run the wildcard certificate issuance command:

bash

```
acme.sh --issue --dns dns_cf \
  -d example.com \
  -d *.example.com \
  --keylength ec-256
```

**Technical Explanation**：

- `--dns dns_cf`: invokes the Cloudflare DNS API engine to automatically add to the domain `_acme-challenge` TXT record, then automatically deletes this temporary record after CA validation succeeds.

- `-d example.com -d *.example.com`: include both the primary domain and its wildcard subdomain in the SAN (Subject Alternative Name) extension of a single certificate to avoid certificate mismatches when accessing the primary domain.

- `--keylength ec-256`: Enforces the ECC algorithm (ECDSA signatures).

## Five. Production Certificate Deployment Standards and Seamless Reloading[#](https://vpsmap.net/en/guides/https-certificates/#section-14)

In automated operations,**Never Point the Web Server's (Nginx) Configuration Directly to `~/.acme.sh/` the internal working directory**. This directory is acme.sh's internal state storage. Its file layout may change with script updates, and default permissions restrict files to root, potentially causing permission problems or broken symbolic links.

The Standard Official Approach Is to Use `acme.sh --install-cert` command to deploy the certificate to the standard system directory and attach a service reload hook.

### Step 1: Plan the Production Certificate Storage Directory[#](https://vpsmap.net/en/guides/https-certificates/#section-15)

bash

```
# 创建符合 FHS 规范的 SSL 存储目录并加固权限
mkdir -p /etc/nginx/ssl/example.com
chmod 750 /etc/nginx/ssl/example.com
```

### Step 2: Install the Certificate and Register a Reload Hook[#](https://vpsmap.net/en/guides/https-certificates/#section-16)

Run the following command to deploy the certificate:

bash

```
acme.sh --install-cert -d example.com --ecc \
  --key-file       /etc/nginx/ssl/example.com/privkey.pem \
  --fullchain-file /etc/nginx/ssl/example.com/fullchain.pem \
  --reloadcmd     "systemctl reload nginx"
```

**Important Parameter Notes**：

- `--ecc`: specifies that the previously issued EC certificate should be processed.

- `--fullchain-file`: must point to the full-chain file containing both the server certificate and intermediate CA certificates. Do not use only the individual `cert.pem`, otherwise mobile devices or some older systems may report an “incomplete/untrusted certificate chain” error.

- `--reloadcmd`: A crucial automation hook. When acme.sh completes a renewal in the background, this command runs automatically. Here, you must use `systemctl reload nginx` rather than `restart`, using Nginx's graceful restart mechanism to load the new certificate without downtime or interrupting existing long-lived connections.

### Step 3: Verify Scheduled Task Health[#](https://vpsmap.net/en/guides/https-certificates/#section-17)

View the system's scheduled task configuration:

bash

```
crontab -l | grep acme.sh
```

You will see a scheduled task similar to the following:

cron

```
42 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
```

acme.sh automatically checks in the early hours each day. For Let's Encrypt certificates valid for 90 days, it defaults to**Day 60**intervenes and automatically performs: API writes TXT -> validate and issue -> copy updates to the production directory -> run `systemctl reload nginx`. The entire process is fully automated and requires no manual intervention.

## Six. Hands-On Production Nginx TLS 1.3 Security Configuration with Strong Encryption[#](https://vpsmap.net/en/guides/https-certificates/#section-18)

After obtaining a high-quality certificate, the web server's protocol-stack configuration determines resistance to attacks and connection latency over the public internet. The following setup combines HTTP/2, TLS 1.3 preference, forward secrecy, HSTS, and OCSP Stapling.

Create a site configuration file in Nginx, for example `/etc/nginx/conf.d/example.com.conf`：

nginx

```
# 1. HTTP 流量全量强制重定向至 HTTPS
server {
    listen 80;
    listen [::]:80;
    server_name example.com *.example.com;

    # 规范化 301 永久重定向
    return 301 https://$host$request_uri;
}

# 2. HTTPS 强加密生产服务配置
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name example.com *.example.com;

    # 证书与私钥路径（指向 install-cert 发布的生产规范路径）
    ssl_certificate     /etc/nginx/ssl/example.com/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/example.com/privkey.pem;

    # ---------------- 协议与加密套件优化 ----------------
    # 彻底禁用已废弃的 SSLv2/v3、TLSv1.0 与 TLSv1.1，仅允许现代安全协议
    ssl_protocols TLSv1.2 TLSv1.3;

    # TLS 1.2 兼容套件推荐（优先具备完全前向安全性的 ECDHE 算法）
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305;

    # 在 TLS 1.3 中该指令已被标准废止；保留 off 可让客户端与服务端协商最优硬件加速算法
    ssl_prefer_server_ciphers off;

    # ---------------- SSL 会话复用与握手优化 ----------------
    # 开启共享会话缓存，10MB 缓存空间约可承载 40000 个长连接握手状态
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 1d;

    # 禁用无状态 Session Ticket（避免因未轮换密钥损害完全前向安全性）
    ssl_session_tickets off;

    # ---------------- OCSP Stapling (在线证书状态装订) ----------------
    # 由服务端预先拉取并缓存证书吊销状态，省去客户端向 CA 查询的往返 RTT
    ssl_stapling on;
    ssl_stapling_verify on;
    ssl_trusted_certificate /etc/nginx/ssl/example.com/fullchain.pem;

    # 必须指定解析 CA OCSP 域名的上游公共 DNS 服务器及超时阈值
    resolver 1.1.1.1 8.8.8.8 valid=300s;
    resolver_timeout 5s;

    # ---------------- 安全响应头加固 ----------------
    # HSTS: 强制客户端浏览器在未来 1 年内必须通过 HTTPS 建立连接
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

    # 基础安全防护头
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "SAMEORIGIN" always;

    # ---------------- 业务路径 ----------------
    root /var/www/html;
    index index.html index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }
}
```

### Validate and Hot-Reload the Configuration[#](https://vpsmap.net/en/guides/https-certificates/#section-19)

After making changes, be sure to validate the configuration syntax before performing a graceful reload:

bash

```
# 测试配置文件语法的正确性
nginx -t

# 确认语法通过（syntax is ok）后，热重载配置
systemctl reload nginx
```

After deploying the configuration, you can use the authoritative assessment service **Qualys SSL Labs** perform a comprehensive security assessment of the site. With the configuration standards above, it will earn the highest rating **A+**.

## Seven. Operational Troubleshooting, Edge Cases, and Instance Lifecycle Interactions[#](https://vpsmap.net/en/guides/https-certificates/#section-20)

In real production operations, certificate renewal is rarely an isolated script action; it is closely linked to DNS propagation, network conditions, and the cloud server lifecycle.

### 1. Manually Force a Simulated Renewal Test[#](https://vpsmap.net/en/guides/https-certificates/#section-21)

After installing the system, you do not need to wait 60 days to verify that the scheduled task works. You can use `--force` parameter to validate the renewal process end to end:

bash

```
acme.sh --renew -d example.com --ecc --force
```

Watch for These Key Stages in the Output Logs:

1. whether the Cloudflare API was successfully called to create the TXT record;

1. whether CA validation has passed;

1. whether the new certificate has been copied to `/etc/nginx/ssl/example.com/`；

1. whether the Nginx process successfully received the reload signal.

### 2. Validation Timeouts Caused by DNS Propagation Delays[#](https://vpsmap.net/en/guides/https-certificates/#section-22)

With DNS providers that propagate changes slowly, Let's Encrypt may fail to resolve a TXT record just written by acme.sh, causing validation errors.

- **Troubleshooting Approach**: Cloudflare API changes usually take effect within seconds. If network instability occurs, you can temporarily set a DNS propagation waiting period before issuance (in seconds):

bash

```
export CF_DNS_SLEEP=120
```

This environment variable forces acme.sh to wait 120 seconds after writing the record before notifying the CA to validate it, effectively avoiding international DNS propagation delays.

### 3. Cascading Effects of Server Lifecycle, Renewals, and Certificate Chains[#](https://vpsmap.net/en/guides/https-certificates/#section-23)

Server downtime or an abnormal billing status is a major blind spot that can cause automated certificate maintenance to fail:

- **Billing and Nonpayment-Related Outage Risks**：

- **BandwagonHost**: Its billing system does not automatically debit a linked credit card or PayPal account without authentication. Under its renewal policy, invoices are generated 7 days before expiration when renewal is enabled, and available account credit can be used. If you do not top up or confirm balance payment in time, the instance stops at expiration, taking Nginx offline and blocking subsequent website access.

- **DMIT**: monthly renewal invoices are also generated 7 days before the instance expires. If an invoice is not paid promptly, the server is generally retained for only 3 days after suspension at expiry; if payment remains overdue, its data will be permanently destroyed.

- **The Silent Certificate Expiration Trap**: although DNS-01 issuance does not depend on the VPS's port 80,**The Host Running Scheduled Tasks Must Be Online and Operating**. If an instance is temporarily shut down for an overdue invoice during acme.sh's 60~90-day renewal window, Cron cannot run. Even after topping up and restoring the instance, browsers may block the site because the certificate has fully expired. Set up regular availability monitoring for production instances and include certificate expiration as a separate externally monitored alert metric.

## Eight. Summary and Automated Operations Checklist[#](https://vpsmap.net/en/guides/https-certificates/#section-24)

By using the lightweight, pure-Shell tool **acme.sh** and **DNS-01 Validation**combined, we have built a fault-tolerant, fully automated HTTPS lifecycle requiring no manual maintenance. Here is a recap of the implementation steps and operating guidelines:

1. **Environment Selection**: on lightweight production VPS instances, avoid bulky Certbot and Snap dependencies and use the minimalist `acme.sh`；

1. **Decouple Validation**: Use finely scoped Cloudflare API Tokens and DNS-01 instead of HTTP-01 to issue wildcard certificates while supporting private-network topologies;

1. **Architecture Standards**: strictly use `--install-cert` Manage production certificates centrally, never directly symlink the internal working directory, and use `--reloadcmd` achieve a seamless, disruption-free reload;

1. **Strong Encryption Configuration**: Uses ECC P-256 throughout, combined with TLS 1.3, forward-secure cipher suites, HSTS, and OCSP Stapling, delivering exceptional handshake performance and strong security over high-latency international links.
