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.comwith your domain name
Some notes:
wwwsubdomain redirects to the apex domain (i.e. visitors ofwww.example.comwill be redirected toexample.com)- Requests without the
Hostheader are rejected ssl_reject_handshakerequires nginx 1.19.4+- HSTS (Strict-Transport-Security) is enabled, learn what this means before proceeding