Skip to content

Commit

Permalink
Enable setting the port and allowPrivateAddress through environment vars
Browse files Browse the repository at this point in the history
By setting

      BEHIND_PROXY: "true"
      HOLLO_PORT: 80
      ALLOW_PRIVATE_ADDRESS: "true"

one allows private addresses and runs on port 80.
  • Loading branch information
HelgeKrueger authored and dahlia committed Nov 1, 2024
1 parent 395bf13 commit 2c72c39
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ SECRET_KEY=secret_key # generate a secret key with `openssl rand -base64 32`
LOG_LEVEL=info
LOG_QUERY=false
BEHIND_PROXY=false
LISTEN_PORT=3000 # if BEHIND_PROXY=true used as port for the server
# Setting ALLOW_PRIVATE_ADDRESS to true disables SSRF (Server-Side Request Forgery) protection
# Set to true to test in local network
# Will be replaced by list of allowed IPs once https://github.com/dahlia/fedify/issues/157
# is implemented.
ALLOW_PRIVATE_ADDRESS=false
REMOTE_ACTOR_FETCH_POSTS=10
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
Expand Down
2 changes: 2 additions & 0 deletions src/federation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ if (getRedisUrl() == null) {
export const federation = createFederation<void>({
kv,
queue,
// biome-ignore lint/complexity/useLiteralKeys: tsc complains about this (TS4111)
allowPrivateAddress: process.env["ALLOW_PRIVATE_ADDRESS"] === "true",
});

federation
Expand Down
6 changes: 5 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ app.get("/favicon.png", async (c) => {

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

export default BEHIND_PROXY ? { fetch: behindProxy(app.fetch.bind(app)) } : app;
export default BEHIND_PROXY
? { fetch: behindProxy(app.fetch.bind(app)), port: HOLLO_PORT }
: app;

0 comments on commit 2c72c39

Please sign in to comment.