openvibers/openvibe.events Commits
Events: unknown GET paths get the app's own 404 page and favicon instead of nginx's bare page (#37)
Changes
@@@ -182,6 +182,15 @@ server {proxy_set_header CF-Connecting-IP $remote_addr;}-- # ── Everything else: no route here ──-- location / { return 404; }++ # ── Everything else: the app answers GET/HEAD (its /favicon.ico, and its own 404 page for browsers or a++ # problem+json for API clients, both with lang and the Frame); other methods are refused here ──++ location / {++ limit_except GET HEAD { deny all; }++ proxy_pass http://127.0.0.1:4300;++ proxy_set_header Host $host;++ proxy_set_header X-Real-IP $remote_addr;++ proxy_set_header X-Forwarded-For $remote_addr;++ proxy_set_header CF-Connecting-IP $remote_addr;++ proxy_set_header X-Forwarded-Proto $scheme;++ }}@@@ -161,6 +161,11 @@ t('deploy/nginx/openvibe.events.conf is the API and product origin, with no rediconst refusals = [conf.indexOf('location ~* ^/metrics(/|$) { return 404; }'), conf.indexOf('location ~* ^/internal(/|$) { return 404; }')];assert.ok(refusals.every((i) => i >= 0), 'metrics and /internal/ are refused');assert.ok(!conf.includes('events.openvibe.network$request_uri'), 'no catch-all redirect to the old API host');++ // The catch-all hands GET/HEAD to the app (its /favicon.ico and its own 404 page with lang), never other methods.++ const catchAll = conf.slice(conf.lastIndexOf(' location / {'));++ assert.match(catchAll, /limit_except GET HEAD \{ deny all; \}/, 'the catch-all only passes GET and HEAD');++ assert.match(catchAll, /proxy_pass http:\/\/127\.0\.0\.1:4300;/, 'and lets the app answer (favicon, 404 page)');++ assert.ok(!/location \/ \{ return 404; \}/.test(conf), 'nginx\'s bare 404 page (no lang) is gone');const old = fs.readFileSync(path.join(__dirname, '..', 'deploy', 'nginx', 'events.openvibe.network.conf'), 'utf8').split('\n').filter((l) => !/^\s*#/.test(l)).join('\n');assert.ok(!old.includes('proxy_pass'), 'events.openvibe.network serves nothing itself');
@@ -182,6 +182,15 @@ server {
@@ -182,6 +182,15 @@ server {
proxy_set_header CF-Connecting-IP $remote_addr;
proxy_set_header CF-Connecting-IP $remote_addr;
}
}
- # ── Everything else: no route here ──
- location / { return 404; }
+ # ── Everything else: the app answers GET/HEAD (its /favicon.ico, and its own 404 page for browsers or a
+ # problem+json for API clients, both with lang and the Frame); other methods are refused here ──
+ location / {
+ limit_except GET HEAD { deny all; }
+ proxy_pass http://127.0.0.1:4300;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $remote_addr;
+ proxy_set_header CF-Connecting-IP $remote_addr;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ }
}
}
@@ -161,6 +161,11 @@ t('deploy/nginx/openvibe.events.conf is the API and product origin, with no redi
@@ -161,6 +161,11 @@ t('deploy/nginx/openvibe.events.conf is the API and product origin, with no redi
const refusals = [conf.indexOf('location ~* ^/metrics(/|$) { return 404; }'), conf.indexOf('location ~* ^/internal(/|$) { return 404; }')];
const refusals = [conf.indexOf('location ~* ^/metrics(/|$) { return 404; }'), conf.indexOf('location ~* ^/internal(/|$) { return 404; }')];
assert.ok(refusals.every((i) => i >= 0), 'metrics and /internal/ are refused');
assert.ok(refusals.every((i) => i >= 0), 'metrics and /internal/ are refused');
assert.ok(!conf.includes('events.openvibe.network$request_uri'), 'no catch-all redirect to the old API host');
assert.ok(!conf.includes('events.openvibe.network$request_uri'), 'no catch-all redirect to the old API host');
+ // The catch-all hands GET/HEAD to the app (its /favicon.ico and its own 404 page with lang), never other methods.
+ const catchAll = conf.slice(conf.lastIndexOf(' location / {'));
+ assert.match(catchAll, /limit_except GET HEAD \{ deny all; \}/, 'the catch-all only passes GET and HEAD');
+ assert.match(catchAll, /proxy_pass http:\/\/127\.0\.0\.1:4300;/, 'and lets the app answer (favicon, 404 page)');
+ assert.ok(!/location \/ \{ return 404; \}/.test(conf), 'nginx\'s bare 404 page (no lang) is gone');
const old = fs.readFileSync(path.join(__dirname, '..', 'deploy', 'nginx', 'events.openvibe.network.conf'), 'utf8')
const old = fs.readFileSync(path.join(__dirname, '..', 'deploy', 'nginx', 'events.openvibe.network.conf'), 'utf8')
.split('\n').filter((l) => !/^\s*#/.test(l)).join('\n');
.split('\n').filter((l) => !/^\s*#/.test(l)).join('\n');
assert.ok(!old.includes('proxy_pass'), 'events.openvibe.network serves nothing itself');
assert.ok(!old.includes('proxy_pass'), 'events.openvibe.network serves nothing itself');