Skip to content

Instantly share code, notes, and snippets.

@adamwalz
Last active July 16, 2019 05:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adamwalz/8108694 to your computer and use it in GitHub Desktop.
Save adamwalz/8108694 to your computer and use it in GitHub Desktop.
Jekyll optimized nginx server configuration used on adamwalz.net
server {
server_name www.adamwalz.net;
return 301 $scheme://adamwalz.net$request_uri;
}
server {
server_name adamwalz.net *.adamwalz.net;
root /home/adamwalz/Sites/adamwalz.net;
access_log /var/log/nginx/adamwalz.net/access.log;
include /etc/nginx/conf.d/jekyll_server.nginxconf;
location @error {
return 307 https://s3-us-west-1.amazonaws.com/adamwalz.net/fatal_error/5xx.html;
}
}
location / {
index index.html index.htm;
if (-f $document_root/maintenance.html) {
return 503;
}
location ~* \.(css|js|html)$ {
expires max;
}
}
location ~* \.(jpg|jpeg|gif|png|ico|woff)$ {
expires max;
access_log off;
add_header Cache-Control public;
}
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 405 /error/405.html;
error_page 503 @maintenance;
error_page 500 501 502 504 /error/5xx.html;
location ^~ /error/ {
internal;
try_files $uri @error;
}
location @maintenance {
rewrite ^(.*)$ /maintenance.html break;
}
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
# For debugging, change level
# [debug|info|notice|warn|error|crit|alert|emerg]
error_log /var/log/nginx/error.log info;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# gzip_vary on;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
include /etc/nginx/sites-enabled/*;
}
server {
server_name preview.adamwalz.net;
root /home/adamwalz/Sites/preview.adamwalz.net;
include /etc/nginx/conf.d/jekyll_server.nginxconf;
location @error {
return 307 https://s3-us-west-1.amazonaws.com/adamwalz.net/fatal_error/5xx.html;
}
}
sudo service nginx start
sudo service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment