Security guide · Romania

How do I install free HTTPS with Let's Encrypt and enable HSTS?

A Let's Encrypt certificate takes minutes to get and renews itself. What people get wrong comes afterwards: the redirect, the TLS versions and HSTS, the header that tells browsers never to try plain HTTP again.

Updated:

Short answer

  1. Install free HTTPS with certbot, which requests the certificate from Let's Encrypt over the ACME protocol and configures it in your web server.
  2. Keep ports 80 and 443 open, because HTTP-01 validation happens on 80, and check that automatic renewal runs, since certificates last 90 days.
  3. Redirect all HTTP traffic to HTTPS with a 301 and allow only TLS 1.2 and 1.3.
  4. Enable HSTS only after all content, subdomains included, works over HTTPS, with max-age=31536000, and add preload last because it is practically irreversible in the short term.
Lifetime of a Let's Encrypt certificate
90 days, automatic renewal
Recommended HSTS max-age
31536000 s (1 year)
Preload list requirements
max-age ≥ 31536000, includeSubDomains, preload, HTTP→HTTPS redirect on the same host
Accepted TLS versions
TLS 1.2 and TLS 1.3

How Let's Encrypt works and why renewal matters

Let's Encrypt is a certificate authority that issues free certificates automatically through the ACME protocol. certbot proves you control the domain by answering a request on port 80 (HTTP-01) or through a DNS record (DNS-01, required for wildcards). Certificates last 90 days precisely so that renewal gets automated. The certbot package installs a systemd timer that tries to renew twice a day; check that it runs and add an external alert on the expiry date.

What HSTS does and when to turn it on

The Strict-Transport-Security header tells the browser to use only HTTPS for your domain for the duration of max-age, even if the user types http:// or follows an old link. It closes the window in which an attacker on the same network can intercept the very first HTTP request. The risk runs the other way: if a subdomain has no valid certificate and you set includeSubDomains, browsers block it for a year. So roll HSTS out in steps: a small max-age, then one year, then includeSubDomains and, last, preload.

  • Check that there is no mixed content, meaning resources loaded over http://
  • Make sure every subdomain, mail and panel ones included, has a valid certificate
  • Disable TLS 1.0 and 1.1, and rely on CRLs for revocation, since Let's Encrypt has dropped OCSP
Directives of the Strict-Transport-Security header
DirectiveRecommended valueEffectWhen to add it
max-age31536000 (1 year)The browser forces HTTPS for this durationOnce the whole site works over HTTPS; start with a small value
includeSubDomainspresentAlso applies to every subdomainOnly when each subdomain has a valid certificate
preloadpresentAllows inclusion in the browsers' preloaded listThe last step; practically irreversible in the short term

Commands and configuration

Let's Encrypt certificate with certbot for Nginx
sudo certbot --nginx -d example.ro -d www.example.ro --redirect
sudo certbot renew --dry-run
systemctl list-timers | grep certbot
Nginx: modern TLS and HSTS
server {
  listen 443 ssl;
  http2 on;
  server_name example.ro www.example.ro;
  ssl_certificate     /etc/letsencrypt/live/example.ro/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/example.ro/privkey.pem;
  ssl_protocols TLSv1.2 TLSv1.3;
  ssl_prefer_server_ciphers off;
  # Start with max-age=300, watch for a week, then raise it to 31536000.
  add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
}

server {
  listen 80;
  server_name example.ro www.example.ro;
  return 301 https://$host$request_uri;
}

Practical examples

Accounting firm in Bucharest with a client portal

The certificate had been installed by hand and nobody noted the date. It expired on a Saturday, and on Monday clients saw a security warning. Moving to certbot with its timer and an external expiry alert removed the problem for good.

Web agency in Timisoara

It enabled HSTS with includeSubDomains on the main domain and forgot that the staging subdomain had a self-signed certificate. The team could no longer open staging in their own browsers. The fix was a low max-age step before the final value.

Common mistakes

  • Treating SSL as a secured site, although HTTPS only encrypts the transport and not the application.
  • Enabling HSTS with preload on day one and then discovering a subdomain without a certificate.
  • Closing port 80 “for security” and breaking HTTP-01 validation at the next renewal.
  • Leaving TLS 1.0 and 1.1 on “for compatibility” with clients that no longer exist.

How 4hosting helps

  • cPanel plans include Let's Encrypt certificates with automatic renewal, with nothing for you to configure.
  • On VPS and dedicated servers, Hardening & Compliance sets up modern TLS, staged HSTS and expiry monitoring from the included hours: 1–8 per month on VPS, 5–10 on dedicated servers depending on the plan and 10 on GPU servers, requested from the client panel, in the “DevOps Services” section.
  • Mailu & SMTP Relay puts valid certificates on the mail subdomains too, a precondition for includeSubDomains.

Related questions

  • Can I get a wildcard certificate from Let's Encrypt?

    Yes, but only through DNS-01 validation: certbot creates a TXT record in your domain's zone through the DNS provider's API. The certificate covers every first-level subdomain. Use it when you have many dynamic subdomains; otherwise separate certificates per subdomain are easier to track.

  • What happens if the certificate expires?

    Browsers show a full-page warning and most visitors leave. API clients refuse the connection. With HSTS active, users cannot even click through the warning. That is why automatic renewal and an external expiry alert are not optional.

  • Is it worth joining the preload list?

    For high-traffic sites with a stable structure, yes: the first visit is protected. For a site that changes subdomains or has internal services without certificates, the risk of locking something out for months is real. Start without preload and decide after a few months of stable HSTS.

Request a security review

A production server starts getting attacked within minutes of receiving a public IP address, however small the project is. This guide ranks the controls by impact, from SSH access to incident response, with the Romanian rules that apply along the way. Every topic has its own page with a short answer, examples and ready-to-use configuration.