Fixes two nginx rule defects found by real nginx in CI
Plain map keys compare case-insensitively, so /Over-Mij was not redirected. A path starting with an encoded backslash could become an open redirect through the trailing-slash rule; it now gets the 404 page. Also makes the tests readable for nginx's workers and less sensitive to the slow CI runner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -65,6 +65,14 @@ process.on('exit', () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Als root (de CI-container) draait de master als root en laat nginx de workers
|
||||
// onder een andere gebruiker (www-data of nobody) draaien. Die kan de
|
||||
// tijdelijke map (mode 700 van mkdtemp) niet openen en geeft overal 403. De
|
||||
// workers draaien daarom ook als root. Zonder root mag de user-directive niet:
|
||||
// nginx waarschuwt dan dat hij alleen voor het hoofdproces als root zin heeft.
|
||||
export const userDirective = (uid: number | undefined) =>
|
||||
uid === 0 ? 'user root;\n' : '';
|
||||
|
||||
// nginx onder Windows wil voorwaartse slashes in de configuratie
|
||||
const slashed = (path: string) => path.replace(/\\/g, '/');
|
||||
|
||||
@@ -113,7 +121,7 @@ export async function startNginx(options: {
|
||||
);
|
||||
await writeFile(
|
||||
confFile,
|
||||
`daemon off;
|
||||
`${userDirective(process.getuid?.())}daemon off;
|
||||
pid "${slashed(join(tmp, 'nginx.pid'))}";
|
||||
error_log "${slashed(errorLog)}";
|
||||
events {}
|
||||
|
||||
Reference in New Issue
Block a user