Created
September 8, 2018 12:11
-
-
Save jermainee/eb2809845bdca80d8771b746022a012d to your computer and use it in GitHub Desktop.
Simple NGINX configuration for static websites with HTTPS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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