Nginx reverse proxy and HTTPS: the certbot flow, measured
A reverse proxy puts nginx in front of your application; certbot handles HTTPS issuance and renewal. Both measured end to end here.
Install
Section titled “Install”sudo dnf install -y nginx certbot python3-certbot-nginxMeasured versions: nginx 1.30.5, certbot 5.8.0. python3-certbot-nginx is the plugin that lets certbot rewrite nginx configs — mandatory.
Reverse proxy: 8009 in front of a local 8081
Section titled “Reverse proxy: 8009 in front of a local 8081”Start a fake backend:
mkdir -p /srv/test && echo proxy-backend-ok | sudo tee /srv/test/index.htmlcd /srv/test && python3 -m http.server 8081 --bind 127.0.0.1/etc/nginx/conf.d/proxy-demo.conf:
server { listen 8009; server_name _;
location / { proxy_pass http://127.0.0.1:8081; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }}sudo nginx -t && sudo systemctl reload nginxcurl -s http://127.0.0.1:8009/Measured: proxy-backend-ok — the chain works. Do not skip the proxy_set_header block: backends recover the real visitor address and protocol from X-Forwarded-*; without them, every log entry and rate limit reads 127.0.0.1.
A production-flavored template
Section titled “A production-flavored template”Real workloads usually need a few more lines:
location / { proxy_pass http://127.0.0.1:8081; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; # WebSocket handshake proxy_set_header Connection "upgrade"; proxy_read_timeout 60s; # slow endpoints shouldn't 504 proxy_buffering off; # required for SSE / streaming}proxy_buffering off is essential for LLM streaming and Server-Sent Events — otherwise nginx buffers until full and the client sees a long stall followed by one dump.
HTTPS: certbot
Section titled “HTTPS: certbot”Prerequisites: the domain’s A record points here, and port 80 is reachable from the internet (Let’s Encrypt’s HTTP-01 check comes in from outside).
sudo certbot --nginx -d docs.example.comAnswer the email and redirect prompts; certbot then issues the certificate, adds a 443 server block to nginx, and installs a reload hook. Certificates land in /etc/letsencrypt/live/<domain>/.
Renewal is automatic (the certbot-renew.timer systemd timer). To test it:
sudo certbot renew --dry-runWhat you can verify without a public domain
Section titled “What you can verify without a public domain”You can get all the way to the last step:
sudo certbot certonly --nginx --dry-run -n -d test.invalidMeasured, this reaches Let’s Encrypt’s validation stage and reports:
Invalid identifiers requested :: Cannot issue for "test.invalid":Domain name does not end with a valid public suffix (TLD)That error proves the plugin loads, the account registers, and the request is well-formed — only a real domain is missing. On a public host, substitute a real one and it signs.
Common traps
Section titled “Common traps”| Symptom | Cause |
|---|---|
certbot: No module named 'pyparsing' | missing plugin dependency; dnf install python3-pyparsing |
--dry-run rejected | only valid with certonly/renew, not run |
| backend logs full of 127.0.0.1 | X-Forwarded-For not forwarded |
| streaming endpoints stall | proxy_buffering still on |
| WebSocket never connects | missing Upgrade/Connection headers |
| bind Permission denied on 8009 | SELinux port label, see above |
Domain name does not end with a valid public suffix | domain nonexistent or not pointed here; LE validation failed up front |
Related pages
Section titled “Related pages”- nginx + PHP sites — full SELinux port-label story
- firewalld — open 80/443
- journalctl —
journalctl -u nginx -p errfor debugging - Upstream: certbot guide