I need to enable a web application to be served from a non-root path (i.e. http://example.com/wiki/ instead of http://example.com/). The application is behind a reverse proxy (nginx). I realized there are at least two approaches to this:
Make the app aware of the path prefix and use it to construct all URLs (Location headers in 3xx redirects, links within HTML docs and addresses in Ajax calls).
Strip the prefix from the request in the reverse proxy (/wiki/index.html becomes /index.html), pass such request to the app, use relative URLs in all HTML docs and Ajax calls (src="./static/foo.jpg", POST "./create-user". Configure the reverse proxy to rewrite Location headers returned in redirects. ('proxy_redirect' nginx directive).
Which approach is better and why?