server { listen 80; server_name jayrup.me; root /usr/share/nginx/html; index index.html; # Helper variable: detect text clients set $want_text 0; if ($http_user_agent ~* "(curl|wget)") { set $want_text 1; } if ($http_accept ~* "text/plain") { set $want_text 1; } # Home location = / { if ($want_text) { rewrite ^ /index.txt break; } try_files /index.html =404; } # Projects location = /projects { if ($want_text) { rewrite ^ /projects.txt break; } try_files /projects.html =404; } # CV location = /cv { if ($want_text) { rewrite ^ /cv.txt break; } try_files /cv.html =404; } # Force correct type for text files location ~ \.txt$ { default_type text/plain; } }