Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Allow self-hosted webhook delivery to private IP addresses (#2232)

Abimael Martell5756b834884d
diff --git a/SELF_HOST.md b/SELF_HOST.md
index 08f80a43b..5ba25dc9b 100644
--- a/SELF_HOST.md
+++ b/SELF_HOST.md
@@ -114,6 +114,9 @@ BULL_AUTH_KEY=CHANGEME
# Maximum RAM usage threshold (0.0-1.0). Worker will reject new jobs when memory usage exceeds this value.
# Default: 0.8 (80%)
# MAX_RAM=0.8
+
+# Set if you'd like to allow local webhooks to be sent to your self-hosted instance
+# ALLOW_LOCAL_WEBHOOKS=true
```
3. Build and run the Docker containers:
diff --git a/apps/api/src/scraper/scrapeURL/engines/utils/safeFetch.ts b/apps/api/src/scraper/scrapeURL/engines/utils/safeFetch.ts
index 031e3beb3..d5a7e82d1 100644
--- a/apps/api/src/scraper/scrapeURL/engines/utils/safeFetch.ts
+++ b/apps/api/src/scraper/scrapeURL/engines/utils/safeFetch.ts
@@ -54,7 +54,11 @@ function makeSecureDispatcher(skipTlsVerification: boolean) {
)!;
const socket: Socket | TLSSocket = (client as any)[socketSymbol];
- if (socket.remoteAddress && isIPPrivate(socket.remoteAddress)) {
+ if (
+ socket.remoteAddress &&
+ isIPPrivate(socket.remoteAddress) &&
+ process.env.ALLOW_LOCAL_WEBHOOKS !== "true"
+ ) {
socket.destroy(new InsecureConnectionError());
}
});
diff --git a/apps/api/src/services/webhook/delivery.ts b/apps/api/src/services/webhook/delivery.ts
index 4edccaa7d..c231d1c68 100644
--- a/apps/api/src/services/webhook/delivery.ts
+++ b/apps/api/src/services/webhook/delivery.ts
@@ -69,7 +69,10 @@ export class WebhookSender {
private async deliver(payload: any, scrapeId?: string): Promise<void> {
const webhookHost = new URL(this.config.url).hostname;
- if (isIPPrivate(webhookHost)) {
+ if (
+ isIPPrivate(webhookHost) &&
+ process.env.ALLOW_LOCAL_WEBHOOKS !== "true"
+ ) {
this.logger.warn("Aborting webhook call to private IP address", {
webhookUrl: this.config.url,
});