diff --git a/docker/nginx.conf b/docker/nginx.conf index 04559fd..eb72ae6 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -19,6 +19,14 @@ http { server notenextra-cse:4200; } + # Decide where to send /_pagefind* based on the page that made the request + map $http_referer $pagefind_upstream { + default http://notenextra-cse; + ~*://[^/]+/Math(?:/|$) http://notenextra-math; + ~*://[^/]+/CSE(?:/|$) http://notenextra-cse; + } + + include /etc/nginx/mime.types; # add extra types @@ -48,6 +56,16 @@ http { access_log off; } + # Send all Pagefind assets (/_pagefind.js and /_pagefind/*) to the chosen app + # ^~ /_pagefind matches both "/_pagefind.js" and "/_pagefind/..." + location ^~ /_pagefind { + proxy_pass $pagefind_upstream; # leaves URI intact (/_pagefind.js, /_pagefind/manifest.json, etc.) + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + location ~ ^/(build|tests|config|lib|3rdparty|templates|data)/ { deny all; }