diff options
| author | CaptainJack2491 <jayrupnakawala@gmail.com> | 2025-12-27 17:04:20 +0000 |
|---|---|---|
| committer | CaptainJack2491 <jayrupnakawala@gmail.com> | 2025-12-27 17:04:20 +0000 |
| commit | a88167389ca14e2ccf37be9a6dac6c5d7e7ae7e2 (patch) | |
| tree | eb56a87009177e2ca5c789501ccafa4224a6d56e /nginx.conf | |
| parent | 54e111ea16e0d0f3cf51b7b07f2dc64884b9152b (diff) | |
updated nginx config to work with the updated deployment
Diffstat (limited to 'nginx.conf')
| -rw-r--r-- | nginx.conf | 60 |
1 files changed, 21 insertions, 39 deletions
@@ -1,48 +1,30 @@ +map $http_user_agent $format_suffix { + "~*curl" ".txt"; + "~*wget" ".txt"; + default ""; +} + +# Also check for Accept: text/plain +map $http_accept $final_suffix { + "~*text/plain" ".txt"; + default $format_suffix; +} + 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; + location / { + # This handles: + # 1. /cv -> /cv.txt (for curl) + # 2. /cv -> /cv.html (for browser) + # 3. /projects/ -> /projects/index.txt (for curl) + try_files $uri$final_suffix $uri.html $uri/index$final_suffix $uri/index.html =404; } - # 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; + # Ensure text files are served correctly + location ~* \.txt$ { + add_header Content-Type text/plain; } } - |
