Skip to content

Instantly share code, notes, and snippets.

@mislav
Last active April 23, 2017 10:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mislav/d677132306fb2448708dd9c200b99c35 to your computer and use it in GitHub Desktop.
Save mislav/d677132306fb2448708dd9c200b99c35 to your computer and use it in GitHub Desktop.
SSL nginx configuration for my personal site using Let's Encrypt https://certbot.eff.org/#ubuntutrusty-nginx
# primary HTTPS config
server {
listen 443 ssl;
server_name mislav.net;
ssl_certificate /etc/letsencrypt/live/mislav.net/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/mislav.net/privkey.pem;
root /home/app/blog/_site;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
# legacy HTTP config
server {
listen 80;
server_name mislav.net;
root /home/app/blog/_site;
# serve letsencrypt verification files over HTTP
location /.well-known {
try_files $uri $uri/ =404;
}
# redirect everything else to HTTPS
location / {
rewrite ^ https://$server_name$request_uri? permanent;
}
}
# legacy domain redirects
server {
listen 80;
server_name www.mislav.net mislav.uniqpath.com;
location /poignant-guide/ {
rewrite ^/poignant-guide(/.*)$ $scheme://poignant.guide$1 permanent;
}
location / {
rewrite ^ https://mislav.net$request_uri? permanent;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment