kolibri
kolibri copied to clipboard
kolibri-server's nginx decodes the peer in zipcontent URLs, so a peer's archive files return 404
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Target branch: release-v0.20.x
Observed behavior
zipContentUrlputs a peer in the path as one encoded segment:zipcontent/http%3A%2F%2Fpeer.example%3A8080%2F/<file>/<path>.- The nginx config kolibri-server generates sends the zip content port to uWSGI with
include uwsgi_params, which setsPATH_INFOto$document_uri. $document_uriis the normalized URI (https://nginx.org/en/docs/http/ngx_http_core_module.html#location):%XXdecoded and adjacent slashes merged. The path reaches Kolibri aszipcontent/http:/peer.example:8080/<file>/<path>.path_regextakes the peer as a single segment with no/, so that path does not match and the view returns 404.- Kolibri's built-in server leaves
%2Fencoded inPATH_INFO, so the same URL matches there. - Every
zipContentUrlcaller sends this URL: the HTML5, safe HTML5, Perseus, QTI and custom channel renderers. #15970 makes H5P and Bloom send it too. - Found in self-review of #15970.
Expected behavior
A peer's archive files load through kolibri-server as they do through Kolibri's built-in server.
User-facing consequences
On a kolibri-server install, HTML5 apps and other archive resources opened from a peer's library in Learn > Library do not load until they are imported.
Steps to reproduce
- Run
kolibri shellon release-v0.20.x. - Match the path the built-in server delivers, then the path nginx delivers:
from kolibri.core.content.zip_wsgi import path_regex f = "a" * 32 + ".h5p" path_regex.match(f"/http:%2F%2Fpeer.example:8080%2F/{f}/content/video.mp4") # match path_regex.match(f"/http:/peer.example:8080/{f}/content/video.mp4") # None
Context
- release-v0.20.x at b19ef0f009;
zipContentUrlandpath_regexhave had this shape since 48c731b5a1 (June 2023). - kolibri-server (
platforms/debian-server), nginx with uWSGI.
Acceptance Criteria
- [ ] Through the nginx config
kolibri_server_setup.pygenerates,zipcontent/<encodeURIComponent(peer)>/<file>/<path>for a known peer returns the embedded file. - [ ] That holds for a peer address with a path prefix, e.g.
http://peer.example:8080/kolibri/. - [ ] The same URLs return the embedded file through Kolibri's built-in server.
- [ ] Local
zipcontent/<file>/<path>requests return the same responses as before on both servers, including an embedded path with a percent-encoded space. - [ ] A test fails when the peer segment arrives the way nginx delivers it and the file is not served.
AI usage
Claude Code found this while reviewing #15970's branch and drafted the issue. It read nginx's uwsgi_params and URI normalization docs, and ran path_regex against both paths in the steps above; it did not run a kolibri-server install.