Use Certbot with STACKIT DNS
This guide shows you how to leverage the DNS01 ACME challenge with Certbot. You will learn to:
- Set up Certbot, Nginx, and the STACKIT Certbot plugin on an Ubuntu server.
- Generate a wildcard certificate for a zone.
- Point an A-record to the server IP.
- Resolve the domain to display Nginx’s web content — all under SSL encryption.
Prerequisites
Section titled “Prerequisites”- Ubuntu Server:
- Ensure you have access to an Ubuntu server, preferably with a public IP for internet accessibility. Though similar steps apply to other Linux distributions, this guide focuses on Ubuntu.
- For this tutorial, we are using a STACKIT Ubuntu VM setup based on this tutorial. Ensure port 22 (SSH), port 80 (HTTP traffic) and port 443 (SSL traffic) are open in the security group settings.
- STACKIT DNS Zone: Have a configured zone, such as “certbot.runs.onstackit.cloud” for this guide.
- Required Credentials: A service account and corresponding authentication service account key are necessary for the deployment process. Certbot will programmatically create and delete a temporary TXT-record in the DNS zone, requiring the service account to have DNS Admin permissions.
Implementation
Section titled “Implementation”- Determine the server’s IP:
You will get an output like that:
Terminal window wget -qO- ifconfig.schwarz | xargs echoFrom here on the guide assumes, that your server’s IPv4 address is193.148.162.182193.148.162.182. Replace this address with your individual server’s IPv4 address. - Configure an A-record:
Set up a wildcard A-Record pointing to your server’s IP. This ensures every subsequent record in the zone resolves to the Ubuntu server, showcasing the wildcard certificate’s utility.

- Install Nginx with apt:
Confirm Nginx is running:
Terminal window sudo apt updatesudo apt install nginxIf everything works you get an output like this:Terminal window curl http://193.148.162.182Nginx on Ubuntu 22.04 defaults to serving documents from /var/www/html. For multiple sites, it’s better to have separate directories. Instead of modifying /var/www/html, we’ll set up a separate structure.<!DOCTYPE html><html><head><title>Welcome to nginx!</title>... - Create a directory for app.certbot.runs.onstackit.cloud:
Create and edit index.html:
Terminal window sudo mkdir -p /var/www/app.certbot.runs.onstackit.cloud/htmlYou get an output like the following:Terminal window sudo vi /var/www/app.certbot.runs.onstackit.cloud/html/index.html<html><head><title>Welcome to app.certbot.runs.onstackit.cloud!</title></head><body><h1>Success!</h1></body></html> - Nginx Server Block Configuration:
Create a new server block:
Insert the appropriate configuration. Ensure you’ve set the correct directory and domain name.
Terminal window sudo vi /etc/nginx/sites-available/app.certbot.runs.onstackit.cloudActivate the new configuration:server {listen 80;listen [::]:80;# ssl block will be needed later# listen 443 ssl;# ssl on;# ssl_certificate /etc/letsencrypt/live/certbot.runs.onstackit.cloud/fullchain.pem;# ssl_certificate_key /etc/letsencrypt/live/certbot.runs.onstackit.cloud/privkey.pem;root /var/www/app.certbot.runs.onstackit.cloud/html;index index.html index.htm index.nginx-debian.html;server_name app.certbot.runs.onstackit.cloud www.app.certbot.runs.onstackit.cloud;location / {try_files $uri $uri/ =404;}}Validate Nginx configurations:Terminal window sudo ln -s /etc/nginx/sites-available/app.certbot.runs.onstackit.cloud /etc/nginx/sites-enabled/If no errors arise, restart Nginx:Terminal window sudo nginx -tTerminal window sudo systemctl restart nginx - Test:
Access
http://app.certbot.runs.onstackit.cloud/in your browser. If successful, you should view the site you’ve just set up.
- Install Certbot:
Up till now, our connection remains unsecured. To enhance security, we will deploy Certbot in conjunction with the STACKIT plugin.
Terminal window sudo apt install python3 python3-venvsudo python3 -m venv /opt/certbot/sudo /opt/certbot/bin/pip install --upgrade pipsudo /opt/certbot/bin/pip install certbot certbot-dns-stackitsudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot - Set Up Authentication Credentials:
For Certbot to autonomously create a TXT record in the zone, it requires authentication. Create new or use existing service account key and download the service account JSON file, for example
service-account.json. If you use a provided private key, the private key has to be added to theservice-account.jsonfile:In case of a provided private key, the{"id": "*SERVICE_ACCOUNT_KEY_ID*","publicKey": "*PUBLIC_KEY*","createdAt": "2025-12-09T07:51:11.569+00:00","keyType": "USER_MANAGED","keyOrigin": "*GENERATED*","keyAlgorithm": "RSA_2048","active": true,"credentials": {"kid": "*SERVICE_ACCOUNT_KEY_ID*","iss": "*SERVICE_ACCOUNT_EMAIL*","sub": "*SERVICE_ACCOUNT_ID*","aud": "https://stackit-service-account-prod.apps.01.cf.eu01.stackit.cloud","privateKey": "*PRIVATE_KEY*"}}service-account.jsondoes not contain the privateKey. The private key can be added with the following command (private-key.pemholds your provided private key,service-account.jsonis the downloaded service account JSON file without the private key):Terminal window jq ". | .credentials.privateKey = \"$(cat private-key.pem | sed 's/$/\\n/g' | tr -d '\n')\"" service-account.json > service-account-with-private-key.json - Generate Wildcard Certificate:
Create a wildcard certificate for your zone:
Once the command executes, Certbot begins creating a temporary TXT-record within the designated zone:
Terminal window sudo certbot certonly \--authenticator dns-stackit \--dns-stackit-project-id \ # your project id--dns-stackit-service-account ./service-account.json \ # your service account json--dns-stackit-propagation-seconds 300 \--server https://acme-v02.api.letsencrypt.org/directory \--agree-tos \-d 'certbot.runs.onstackit.cloud' \-d '*.certbot.runs.onstackit.cloud'
- Record Propagation:
If the propagation is successful, Certbot will retract the temporary record. Wait for the process to complete, which could take up to 300 seconds or more. A successful outcome will be indicated with an appropriate message:
You can confirm the presence of the certificate on the machine using:Successfully received certificate.Certificate is saved at: /etc/letsencrypt/live/certbot.runs.onstackit.cloud/fullchain.pemKey is saved at: /etc/letsencrypt/live/certbot.runs.onstackit.cloud/privkey.pemThis certificate expires on 2023-12-26.These files will be updated when the certificate renews.NEXT STEPS:- The certificate will need to be renewed before it expires. Certbot can automatically renew the certificate in the background, but you may need to take steps to enable that functionality. See https://certbot.org/renewal-setup for instructions.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -If you like Certbot, please consider supporting our work by:* Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate* Donating to EFF: https://eff.org/donate-le- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -You get an output like this:
Terminal window sudo certbot certificates- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Found the following certs:Certificate Name: certbot.runs.onstackit.cloudSerial Number: 3e826ad25e4a1ef87e91cfd1d34979bf412Key Type: ECDSADomains: certbot.runs.onstackit.cloud *.certbot.runs.onstackit.cloudExpiry Date: 2023-12-26 13:23:19+00:00 (VALID: 90 days)Certificate Path: /etc/letsencrypt/live/certbot.runs.onstackit.cloud/fullchain.pemPrivate Key Path: /etc/letsencrypt/live/certbot.runs.onstackit.cloud/privkey.pem- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Enable SSL for Nginx:
Uncomment the previously commented-out SSL configuration in the Nginx configuration file to activate SSL:
You get an output like the following:
Terminal window sudo vi /etc/nginx/sites-available/app.certbot.runs.onstackit.cloudOnce the modifications are made, restart Nginx to implement the updated configuration:server {listen 80;listen [::]:80;listen 443 ssl;ssl on;ssl_certificate /etc/letsencrypt/live/certbot.runs.onstackit.cloud/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/certbot.runs.onstackit.cloud/privkey.pem;root /var/www/app.certbot.runs.onstackit.cloud/html;index index.html index.htm index.nginx-debian.html;server_name app.certbot.runs.onstackit.cloud www.app.certbot.runs.onstackit.cloud;location / {try_files $uri $uri/ =404;}}Terminal window sudo systemctl restart nginx - Testing the Secure Connection:
With the certificate now in place, access https://app.certbot.runs.onstackit.cloud/ in your browser. The connection should be SSL-encrypted, ensuring a secure browsing experience.
