Skip to content

Commit 2c72c39

Browse files
HelgeKruegerdahlia
authored andcommitted
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 395bf13 commit 2c72c39

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
@@ -110,6 +110,8 @@ if (getRedisUrl() == null) {
110110
export const federation = createFederation<void>({
111111
kv,
112112
queue,
113+
// biome-ignore lint/complexity/useLiteralKeys: tsc complains about this (TS4111)
114+
allowPrivateAddress: process.env["ALLOW_PRIVATE_ADDRESS"] === "true",
113115
});
114116

115117
federation

src/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,9 @@ app.get("/favicon.png", async (c) => {
3131

3232
// biome-ignore lint/complexity/useLiteralKeys: tsc complains about this (TS4111)
3333
const BEHIND_PROXY = process.env["BEHIND_PROXY"] === "true";
34+
// biome-ignore lint/complexity/useLiteralKeys: tsc complains about this (TS4111)
35+
const HOLLO_PORT = Number.parseInt(process.env["LISTEN_PORT"] ?? "3000", 10);
3436

35-
export default BEHIND_PROXY ? { fetch: behindProxy(app.fetch.bind(app)) } : app;
37+
export default BEHIND_PROXY
38+
? { fetch: behindProxy(app.fetch.bind(app)), port: HOLLO_PORT }
39+
: app;

0 commit comments

Comments
 (0)