Skip to content

Instantly share code, notes, and snippets.

@adamrunner
Last active November 18, 2023 18:27
Show Gist options
  • Save adamrunner/d154e202aac6075e6f96fe8cdb66cff6 to your computer and use it in GitHub Desktop.
Save adamrunner/d154e202aac6075e6f96fe8cdb66cff6 to your computer and use it in GitHub Desktop.
Server Directive for Nginx, redirect from HTTP to HTTPS.
#NOTE: Redirect to HTTPS
server {
listen 80;
listen [::]:80;
server_name example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
#NOTE: Comment out following line if ipv6 is not supported
listen [::]:443 ssl;
ssl_certificate /etc/ssl/certs/adamrunner.dev.crt;
ssl_certificate_key /etc/ssl/private/adamrunner.dev.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# ...
#NOTE: location blocks, etc go here...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment