Created
October 24, 2021 13:02
-
-
Save lfuelling/5ddbc169d091a302cd1ff35a630ce1af to your computer and use it in GitHub Desktop.
Jekyll NGINX Config
This file contains 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 [::]:80; | |
server_name example.com; | |
return 301 https://$host$request_uri; | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name example.com; | |
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; | |
ssl_protocols TLSv1.3 TLSv1.2; | |
ssl_prefer_server_ciphers on; | |
ssl_dhparam /etc/nginx/dhparam.pem; # openssl dhparam -out /etc/nginx/dhparam.pem 4096 | |
ssl_ciphers EECDH+AESGCM:EDH+AESGCM; | |
ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0 | |
ssl_session_timeout 10m; | |
ssl_session_cache shared:SSL:10m; | |
ssl_session_tickets off; # Requires nginx >= 1.5.9 | |
ssl_stapling on; # Requires nginx >= 1.3.7 | |
ssl_stapling_verify on; # Requires nginx => 1.3.7 | |
resolver 8.8.8.8 8.8.4.4 valid=300s; | |
resolver_timeout 5s; | |
autoindex off; | |
server_tokens off; | |
error_log /var/log/nginx/example.err; | |
access_log /var/log/nginx/example.log; | |
gzip on; | |
gzip_comp_level 6; | |
gzip_min_length 100; | |
gzip_types *; | |
root /var/www/example; | |
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"; | |
add_header X-Frame-Options DENY; | |
add_header X-Content-Type-Options nosniff; | |
add_header X-XSS-Protection "1; mode=block"; | |
if ($request_uri = /index.html) { | |
return 301 /; # Rewrite index.html to / for better SEO | |
} | |
rewrite ^(/.*)\.html(\?.*)?$ $1$2 permanent; | |
rewrite ^/(.*)/$ /$1 permanent; | |
index index.html; | |
try_files $uri/index.html $uri.html $uri/ $uri =404; | |
error_page 404 /404.html; | |
location = /404.html { | |
internal; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment