A simple nginx configuration template for HTTPS websites. Tested on Debian 11 with nginx 1.22.0 and openssl 1.1.1n. Partially based on ssl-config.
Quick instructions:
- Obtain SSL certs. I use certbot:
certbot certonly --nginx -d example.com -d www.example.com
- Copy the contents of the repository to
/etc/nginx/
and replace all occurrences ofexample.com
with your domain name
Some notes:
www
subdomain redirects to the apex domain (i.e. visitors ofwww.example.com
will be redirected toexample.com
)- Requests without the
Host
header are rejected ssl_reject_handshake
requires nginx 1.19.4+- HSTS (Strict-Transport-Security) is enabled, learn what this means before proceeding