Skip to content
Search Fedora

    Browse this documentation

    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.

    Terminal window
    sudo dnf install -y nginx certbot python3-certbot-nginx

    Measured 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:

    Terminal window
    mkdir -p /srv/test && echo proxy-backend-ok | sudo tee /srv/test/index.html
    cd /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;
    }
    }
    Terminal window
    sudo nginx -t && sudo systemctl reload nginx
    curl -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.

    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.

    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).

    Terminal window
    sudo certbot --nginx -d docs.example.com

    Answer 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:

    Terminal window
    sudo certbot renew --dry-run

    What 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:

    Terminal window
    sudo certbot certonly --nginx --dry-run -n -d test.invalid

    Measured, 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.

    SymptomCause
    certbot: No module named 'pyparsing'missing plugin dependency; dnf install python3-pyparsing
    --dry-run rejectedonly valid with certonly/renew, not run
    backend logs full of 127.0.0.1X-Forwarded-For not forwarded
    streaming endpoints stallproxy_buffering still on
    WebSocket never connectsmissing Upgrade/Connection headers
    bind Permission denied on 8009SELinux port label, see above
    Domain name does not end with a valid public suffixdomain nonexistent or not pointed here; LE validation failed up front