Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions deploy/nginx/limits.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,28 @@ describe('per-client request limits', () => {
});
}
});

/**
* Uploads must reach the services: Java's own cap is 50 MiB, and a result for
* many samples is several megabytes. local.conf once set nothing, so nginx's
* 1 MB default refused local uploads that every deployment accepted.
*/
const JAVA_UPLOAD_CAP_MB = 50;

describe('request body limits', () => {
for (const file of ['dev.conf', 'release.conf', 'production.conf', 'local.conf']) {
it(`${file} lets an upload of Java's size through`, () => {
const conf = readFileSync(join(__dirname, file), 'utf8');
// Every value, in any unit nginx takes: matching only "64m" let a smaller
// limit written as "512k" pass unseen. A value it cannot read fails.
const values = [...conf.matchAll(/^\s*client_max_body_size\s+(\S+);/gm)].map((m) => m[1]);
expect(values.length, 'no client_max_body_size').toBeGreaterThan(0);
const unit: Record<string, number> = { '': 1, k: 1024, m: 1024 ** 2, g: 1024 ** 3 };
for (const value of values) {
const parsed = /^(\d+)([kKmMgG]?)$/.exec(value);
const bytes = parsed ? Number(parsed[1]) * unit[parsed[2].toLowerCase()] : NaN;
expect([value, bytes >= JAVA_UPLOAD_CAP_MB * 1024 ** 2]).toEqual([value, true]);
}
});
}
});
4 changes: 4 additions & 0 deletions deploy/nginx/local.conf
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ server {
listen 80;
server_name localhost;

# As every deployment: a result for many samples is several megabytes, and
# nginx's 1 MB default refused local uploads the deployments accept.
client_max_body_size 64m;

# The Tina admin is reachable here, and deliberately so: editing content is
# the point of running locally. Every deployed environment denies it.
location ~ ^/admin(/|$) {
Expand Down
8 changes: 3 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"express": "4.22.3",
"fflate": "0.8.3",
"gifenc": "1.0.3",
"http-proxy-middleware": "3.0.7",
"immer": "^10.2.0",
"lodash": "^4.18.1",
"marked": "^17.0.6",
Expand Down
4 changes: 2 additions & 2 deletions specs/010-java-services/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ Each cutover is one PR. It adds the group's patterns to node's table, one nginx

## Phase 8: Polish and side findings

- [ ] T054 [P] Set `client_max_body_size` in `deploy/nginx/local.conf` to match the other deployments (64 MB), so local uploads over 1 MB are not refused. Test it with `deploy/nginx/test-config.sh`.
- [ ] T055 [P] Declare the proxy package that `projects/website-angular/src/scripts/serve-prod.js` uses in `package.json` (it is only present as a dev-only transitive dependency), and check the lockfile changes only that entry
- [x] T054 [P] Set `client_max_body_size` in `deploy/nginx/local.conf` to match the other deployments (64 MB), so local uploads over 1 MB are not refused. Test it with `deploy/nginx/test-config.sh`. — #508
- [x] T055 [P] Declare the proxy package that `projects/website-angular/src/scripts/serve-prod.js` uses in `package.json` (it is only present as a dev-only transitive dependency), and check the lockfile changes only that entry — #508
- [ ] T056 Update `specs/006-content-service-to-node/tasks.md` Phase 9 rows with the PR that moved each Java-homed operation, as each moves
- [ ] T057 Update the curator-facing documents if any reader-visible behaviour is touched by a cutover (constitution: Development Workflow)
- [ ] T058 [EXT] Decide the analysis report's species overview figure. The PDF report embeds the retired Fireworks image, drawn by Java's fireworks-exporter; the site's overview is now the Reacfoam (Voronoi) map. Showing that in the report needs analysis-report changed upstream (its owners) or the figure supplied to it.
Expand Down
Loading