Skip to content

Instantly share code, notes, and snippets.

@jermainee
Created September 8, 2018 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jermainee/eb2809845bdca80d8771b746022a012d to your computer and use it in GitHub Desktop.
Save jermainee/eb2809845bdca80d8771b746022a012d to your computer and use it in GitHub Desktop.
Simple NGINX configuration for static websites with HTTPS
server {
listen 80;
listen 443 ssl;
server_name example.com *.example.com;
error_log /var/log/nginx/example-com.error.log error;
if ($scheme != "https") {
return 301 https://$server_name$request_uri;
}
if ($host != "example.com") {
return 301 https://$server_name$request_uri;
}
root /var/www/example/;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
#include /etc/nginx/includes/minify.conf;
include /etc/nginx/includes/caching.conf;
include /etc/nginx/includes/ssl.conf;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment