Skip to content

Instantly share code, notes, and snippets.

@abrahamvegh
Created March 17, 2013 07:18
Show Gist options
  • Save abrahamvegh/5180476 to your computer and use it in GitHub Desktop.
Save abrahamvegh/5180476 to your computer and use it in GitHub Desktop.
# Requirements:
# 1. No www.
# 2. Always SSL.
# 3. Full IPv4 and IPv6 compatibility.
#
# If you can do better than this, feel free to improve.
# The server in question only serves a single domain.
# Pesky version strings
server_tokens off;
server
{
listen 80 default;
listen [::]:80 default ipv6only=on;
# Force no-WWW and SSL
rewrite ^ https://domain.com$request_uri? permanent;
}
ssl_certificate /etc/nginx/ssl/certificate.pem;
ssl_certificate_key /etc/nginx/ssl/private.key;
server
{
listen 443;
listen [::]:443;
ssl on;
# Force no-WWW
server_name www.domain.com;
rewrite ^ https://domain.com$request_uri? permanent;
}
server
{
listen 443 default;
listen [::]:443 default ipv6only=on;
ssl on;
access_log /www/access.log;
root /www/public;
index index.html index.htm;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment