Skip to content

Commit 85ccbed

Browse files
committed
Block intended proxy abuse
This doesn't actually work - we don't proxy traffic. But we do return a response, which I think some bots are assuming is traffic being proxied. We now reject these explicitly to hopefully stop them trying.
1 parent 447a310 commit 85ccbed

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/http-handler.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ function createHttpRequestHandler(options: {
3939
}): RequestHandler {
4040
return async function handleRequest(req, res) {
4141
const protocol = `http${req.socket instanceof TLSSocket ? 's' : ''}`;
42+
43+
if (!req.url!.startsWith('/')) {
44+
// Absolute URL. Block requests unless they're for us personally. We
45+
// don't accept proxying here (lots of attempted abuse load).
46+
const url = new URL(req.url!);
47+
if (!url.hostname.endsWith(options.rootDomain)) {
48+
res.writeHead(400, { connection: 'close' });
49+
res.end();
50+
}
51+
}
52+
4253
const url = new URL(req.url!, `${protocol}://${
4354
req.headers[':authority'] ?? req.headers['host']
4455
}`);

0 commit comments

Comments
 (0)