Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowed referrer issue when listening on 0.0.0.0 #11

Open
Vigilans opened this issue Oct 12, 2022 · 1 comment
Open

Allowed referrer issue when listening on 0.0.0.0 #11

Vigilans opened this issue Oct 12, 2022 · 1 comment

Comments

@Vigilans
Copy link
Contributor

Vigilans commented Oct 12, 2022

目前可以通过手动修改params.jsonlistenList中的host来监听127.0.0.1以外的IP。不过设置为监听0.0.0.0后,运行时会出现rejected disallowed referer的报错。

这是由于以下代码中:

const refererRegEx = new RegExp(`^(http|https)://(magireco\\.local|${selfHost.replace(/\./g, "\\.")})(|:${selfPort})($|/.*)`);
const isReferrerAllowed = req.headers.referer?.match(refererRegEx) != null;
if (!isHomepage && !isCACert && !isReferrerAllowed) {
console.error(`rejected disallowed referer`);
res.writeHead(403, { ["Content-Type"]: "text/plain" });
res.end("403 Forbidden");
return;
}

refererRegEx使用selfHost的字符串值来匹配网页IP所导致的。当selfHost0.0.0.0时,通过任何IP访问control interface都将通不过这个referrer检查。

@segfault-bilibili
Copy link
Owner

预计用magireco.local这个域名走HTTP代理就可以访问了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants