Skip to content

Commit 06da44d

Browse files
committed
Enable setting the port and allowPrivateAddress through environment vars
By setting BEHIND_PROXY: "true" HOLLO_PORT: 80 ALLOW_PRIVATE_ADDRESS: "true" one allows private addresses and runs on port 80.
1 parent 876c624 commit 06da44d

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

.env.sample

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ SECRET_KEY=secret_key # generate a secret key with `openssl rand -base64 32`
55
LOG_LEVEL=info
66
LOG_QUERY=false
77
BEHIND_PROXY=false
8+
LISTEN_PORT=3000 # if BEHIND_PROXY=true used as port for the server
9+
# Setting ALLOW_PRIVATE_ADDRESS to true disables SSRF (Server-Side Request Forgery) protection
10+
# Set to true to test in local network
11+
# Will be replaced by list of allowed IPs once https://github.com/dahlia/fedify/issues/157
12+
# is implemented.
13+
ALLOW_PRIVATE_ADDRESS=false
814
REMOTE_ACTOR_FETCH_POSTS=10
915
AWS_ACCESS_KEY_ID=
1016
AWS_SECRET_ACCESS_KEY=

src/federation/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ if (getRedisUrl() == null) {
109109
export const federation = createFederation<void>({
110110
kv,
111111
queue,
112+
// biome-ignore lint/complexity/useLiteralKeys: tsc complains about this (TS4111)
113+
allowPrivateAddress: process.env["ALLOW_PRIVATE_ADDRESS"] === "true",
112114
});
113115

114116
federation

src/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@ app.get("/nodeinfo/2.0", (c) => c.redirect("/nodeinfo/2.1"));
2020

2121
// biome-ignore lint/complexity/useLiteralKeys: tsc complains about this (TS4111)
2222
const BEHIND_PROXY = process.env["BEHIND_PROXY"] === "true";
23+
// biome-ignore lint/complexity/useLiteralKeys: tsc complains about this (TS4111)
24+
const HOLLO_PORT = Number.parseInt(process.env["LISTEN_PORT"] ?? "3000", 10);
2325

24-
export default BEHIND_PROXY ? { fetch: behindProxy(app.fetch.bind(app)) } : app;
26+
export default BEHIND_PROXY
27+
? { fetch: behindProxy(app.fetch.bind(app)), port: HOLLO_PORT }
28+
: app;

0 commit comments

Comments
 (0)