Mark Ku's Blog

Problem

I previously used Windows Certbot to obtain a free HTTPS certificate, but it had to be renewed manually every three months — which was tedious. The nginx-certbot Docker container solves this by renewing the certificate automatically.

Environment

  • QNAP TS-253D running Container Station

Installation

1. Create > Search for "staticfloat/nginx-certbot" on Docker Hub > Install

QNAP Container Station displaying staticfloat/nginx-certbot Docker image for ins
QNAP Container Station displaying staticfloat/nginx-certbot Docker image for ins

2. Mount the following folders (Docker Volumes)

PurposeNAS pathContainer path
nginx config files/share/Container/data/proxy-protocol/etc/nginx/conf.d
Let's Encrypt logs/share/Container/data/proxy-protocol/log/var/log/letsencrypt
Existing Let's Encrypt certificate directoryContainer/data/proxy-protocol/letsencrypt/etc/letsencrypt
nginx web root/usr/share/nginx/htmlContainer/data/proxy-Container/data/proxy-protocol/web
QNAP Container Station UI showing container creation with Let's Encrypt director
QNAP Container Station UI showing container creation with Let's Encrypt director

3. Set environment variables

CERTBOT_EMAIL — the email address you used when originally requesting the HTTPS certificate.

QNAP Container Station creating container with Certbot email variable
QNAP Container Station creating container with Certbot email variable

4. Copy your existing certificate to the designated path

Windows File Explorer showing Let's Encrypt certificate files for www.letgo.com.
Windows File Explorer showing Let's Encrypt certificate files for www.letgo.com.

5. Write the nginx config file

upstream frp {
	server 34.80.106.95:80;  # 这个是frp_server的内网ip和http监听端口
}

server
	{
	
	listen 443 ssl http2 proxy_protocol;
	listen [::]:443 ssl http2;
	server_name www.letgo.com.tw; # local server ip

	set_real_ip_from 172.31.0.1; # frp client ip
	real_ip_recursive on;
	real_ip_header  proxy_protocol;


	    ssl_certificate     /etc/letsencrypt/live/www.letgo.com.tw/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/www.letgo.com.tw/privkey.pem;
	
	ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;

	ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
	ssl_prefer_server_ciphers on;
	ssl_session_cache shared:SSL:10m;
	ssl_session_timeout 10m;
	add_header Strict-Transport-Security "max-age=31536000";	

	location / {
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_protocol_addr;		
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_pass http://192.168.50.52:8890/; # your local application ip
	}
}
QNAP Container Station proxy-protocol folder with letsencrypt and nginx.conf
QNAP Container Station proxy-protocol folder with letsencrypt and nginx.conf

6. Start the container — it will check weekly and automatically renew your free HTTPS certificate.

Notes

  • Do not delete the letsencrypt folder; doing so will cause the next renewal to fail.
  • My network setup uses frp. Since frp cannot distinguish between HTTP and HTTPS and automatically upgrades to HTTPS, I handled the initial HTTP-01 challenge by temporarily routing traffic through IIS for verification.

Author

Mark Ku

擁有 10+ 年經驗的資深軟體工程師,現為 AI 應用 Builder,專注於大型平台架構與簡化複雜系統設計,從電商系統到訂閱與收費平台,結合 AI Agent、AI 整合與自動化開發,打造高效率且可持續演進的產品技術基礎。Read More

Found this useful?

The author's free tools, daily podcasts and newsletter are all here.

Mark Ku · This article is licensed under CC BY 4.0. Credit the author and link back to the original when reusing it.

Comments

Subscribe to Newsletter

Subscribe to get new posts delivered instantly — never miss a tech share.

By submitting, you agree to receive emails. You can anytime.

Popular Posts

View all
Mark Ku
··602

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution
Mark Ku
··490

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.
Mark Ku
··333

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki
Mark Ku
··264

Training Your Own AI Voice: Hardware Requirements, Open-Source Model Comparison, and LoRA Fine-Tuning

Training Your Own AI Voice: Hardware Requirements, Open-Source Model Comparison, and LoRA Fine-Tuning
Mark Ku
··221

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1
Mark Ku
··215

Setting Up Samba on Ubuntu to Share Folders with Windows 11

Setting Up Samba on Ubuntu to Share Folders with Windows 11