map $http_user_agent $format_suffix { "~*curl" ".txt"; "~*wget" ".txt"; default ""; } map $http_accept $final_suffix { "~*text/plain" ".txt"; default $format_suffix; } server { listen 80; server_name jayrup.me; root /usr/share/nginx/html; # Don't leak nginx version on error pages / server header server_tokens off; # Gzip compression gzip on; gzip_vary on; gzip_min_length 1024; gzip_proxied any; gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss image/svg+xml; # Security headers add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; # Static asset caching location ~* \.(ico|css|js|gif|jpe?g|png|svg|woff2?)$ { expires 30d; add_header Cache-Control "public, no-transform"; } # Compatibility for assets prefix location = /assets/public_key { try_files /public_key /assets/public_key =404; } location = /assets/dissertation.pdf { try_files /dissertation.pdf /assets/dissertation.pdf =404; } # Serve PDFs directly location ~* \.pdf$ { add_header Content-Type application/pdf; add_header Content-Disposition inline; try_files $uri =404; } # /cv should point to the PDF or plaintext cv location = /cv { try_files /cv$final_suffix /cv/index$final_suffix /cv.pdf =404; } # /dissertation serves summary page or PDF fallback location = /dissertation { try_files /projects/dis/index$final_suffix /projects/dis/index.html /projects/dis$final_suffix /dissertation.pdf =404; } location / { try_files $uri$final_suffix $uri.html $uri/index$final_suffix $uri/index.html =404; } location ~* \.txt$ { add_header Content-Type text/plain; } }