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 | |
| parent | 54e111ea16e0d0f3cf51b7b07f2dc64884b9152b (diff) | |
updated nginx config to work with the updated deployment
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | compose.yml | 4 | ||||
| -rwxr-xr-x | deploy.sh | 4 | ||||
| -rw-r--r-- | nginx.conf | 60 |
4 files changed, 30 insertions, 40 deletions
@@ -1,3 +1,5 @@ /public/ /.quarto/ + +**/*.quarto_ipynb diff --git a/compose.yml b/compose.yml index b884097..60536f4 100644 --- a/compose.yml +++ b/compose.yml @@ -6,10 +6,12 @@ services: ports: - "8080:80" volumes: - - ./:/usr/share/nginx/html:ro + # Mount ONLY the public folder to the Nginx root + - ./public:/usr/share/nginx/html:ro - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro networks: - nginx_default + networks: nginx_default: external: true @@ -18,3 +18,7 @@ find . -name "*.qmd" -not -path "./.*" -not -path "./public/*" | while read -r f # Render to plain text directly into the correct public sub-directory quarto render "$file" --to plain --output "${base_name}.txt" --output-dir "public/$rel_dir" done + +echo "Pushing to vps" + +rsync -avz --delete public/ jayrup.me:~/homepage/public/ @@ -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; } } - |
