Skip to content

Instantly share code, notes, and snippets.

@andrei-markeev
Created November 17, 2024 15:00
Show Gist options
  • Save andrei-markeev/3c03efba9791f0e9630396bc6df4be58 to your computer and use it in GitHub Desktop.
Save andrei-markeev/3c03efba9791f0e9630396bc6df4be58 to your computer and use it in GitHub Desktop.
Force https with NGINX
server {
listen 80;
server_name mydomain.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name mydomain.com;
add_header Strict-Transport-Security "max-age=31536000" always;
ssl_certificate /path/to/mydomain.com.crt;
ssl_certificate_key /path/to/mydomain.com.key;
# ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment