Skip to content

Commit 2a921e5

Browse files
committed
Replace HOST with BIND, which is the more appropriate name for this option
1 parent df42c80 commit 2a921e5

File tree

7 files changed

+65
-72
lines changed

7 files changed

+65
-72
lines changed

.env.sample

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
DATABASE_URL=postgresql://user:password@localhost:5432/dbname
22
SENTRY_DSN=
3-
HOME_URL=https://example.com/ # optional; if present, the home page will redirect to this URL
43
SECRET_KEY=secret_key # generate a secret key with `openssl rand -base64 32`
4+
HOME_URL=https://example.com/ # optional; if present, the home page will redirect to this URL
5+
56
LOG_LEVEL=info
67
LOG_QUERY=false
8+
79
BEHIND_PROXY=false
8-
LISTEN_PORT=3000
10+
PORT=3000
11+
# BIND=localhost
12+
913
# Setting ALLOW_PRIVATE_ADDRESS to true disables SSRF (Server-Side Request Forgery) protection
1014
# Set to true to test in local network
1115
# Will be replaced by list of allowed IPs once https://github.com/dahlia/fedify/issues/157
1216
# is implemented.
1317
ALLOW_PRIVATE_ADDRESS=false
18+
1419
REMOTE_ACTOR_FETCH_POSTS=10
20+
1521
DRIVE_DISK=
1622
ASSET_URL_BASE=
1723
FS_ASSET_PATH=

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Version 0.6.0
66

77
To be released.
88

9-
- Added the `HOST` environment variable to specify the host address to
9+
- Added the `BIND` environment variable to specify the host address to
1010
listen on. [[#114] by Emelia Smith]
1111

1212
- The theme color of the profile page is now customizable. The list of all

bin/server.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@ configureSentry(process.env["SENTRY_DSN"]);
1212
const BEHIND_PROXY = process.env["BEHIND_PROXY"] === "true";
1313

1414
// biome-ignore lint/complexity/useLiteralKeys: tsc complains about this (TS4111)
15-
const LISTEN_HOST = process.env["HOST"];
15+
const BIND = process.env["BIND"];
1616

1717
// biome-ignore lint/complexity/useLiteralKeys: tsc complains about this (TS4111)
18-
const LISTEN_PORT = Number.parseInt(process.env["PORT"] ?? "3000", 10);
18+
const PORT = Number.parseInt(process.env["PORT"] ?? "3000", 10);
1919

20-
if (!Number.isInteger(LISTEN_PORT)) {
20+
if (!Number.isInteger(PORT)) {
2121
console.error("Invalid PORT: must be an integer");
2222
process.exit(1);
2323
}
2424

25-
if (LISTEN_HOST && LISTEN_HOST !== "localhost" && !isIP(LISTEN_HOST)) {
26-
console.error("Invalid HOST: must be an IP address, if specified");
25+
if (BIND && BIND !== "localhost" && !isIP(BIND)) {
26+
console.error(
27+
"Invalid BIND: must be an IP address or localhost, if specified",
28+
);
2729
process.exit(1);
2830
}
2931

@@ -32,12 +34,13 @@ serve(
3234
fetch: BEHIND_PROXY
3335
? behindProxy(app.fetch.bind(app))
3436
: app.fetch.bind(app),
35-
port: LISTEN_PORT,
36-
hostname: LISTEN_HOST ?? "localhost",
37+
port: PORT,
38+
hostname: BIND,
3739
},
3840
(info) => {
3941
let host = info.address;
40-
if (LISTEN_HOST === "localhost") {
42+
// We override it here to show localhost instead of what it resolves to:
43+
if (BIND === "localhost") {
4144
host = "localhost";
4245
} else if (info.family === "IPv6") {
4346
host = `[${info.address}]`;

docs/src/content/docs/install/env.mdx

Lines changed: 42 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,21 @@ title: Environment variables
33
description: How to configure Hollo using environment variables.
44
---
55

6-
import { Aside, Badge } from '@astrojs/starlight/components';
6+
import { Aside, Badge } from "@astrojs/starlight/components";
77

8-
Hollo is configured using environment variables. You can set them in an *.env*
8+
Hollo is configured using environment variables. You can set them in an _.env_
99
file in the root directory of the project, or you can set them using Docker's
1010
`-e`/`--env` option or Railway's environment variables.
1111

12-
13-
Basic settings
14-
--------------
12+
## Basic settings
1513

1614
### `PORT` <Badge text="Optional" /> <Badge text="Unused in Railway" variant="tip" />
1715

18-
The port number to listen on. 3000 by default.
19-
20-
### `HOST` <Badge text="Optional" /> <Badge text="Unused in Railway" variant="tip" />
16+
The port number to listen on. 3000 by default.
2117

22-
The host address to listen on. Must be a valid IP address or `localhost`.
18+
### `BIND` <Badge text="Optional" /> <Badge text="Unused in Railway" variant="tip" />
2319

24-
`localhost` by default.
20+
The address to listen on. Must be a valid IP address or `localhost`.
2521

2622
### `DATABASE_URL` <Badge text="Unused in Railway" variant="tip" />
2723

@@ -30,30 +26,30 @@ The URL of the PostgreSQL database, e.g.,
3026

3127
### `SECRET_KEY` <Badge text="Unused in Railway" variant="tip" />
3228

33-
The secret key for securing the session. You can generate a random secret key
29+
The secret key for securing the session. You can generate a random secret key
3430
using the following command:
3531

36-
~~~~ sh frame="none"
32+
```sh frame="none"
3733
openssl rand -hex 32
38-
~~~~
34+
```
3935

4036
### `TZ` <Badge text="Optional" />
4137

42-
The time zone of the application. It has to be a valid time zone identifier,
38+
The time zone of the application. It has to be a valid time zone identifier,
4339
e.g., `UTC`, `America/New_York`, `Asia/Tokyo`.
4440

4541
`UTC` by default.
4642

4743
### `BEHIND_PROXY` <Badge text="Optional" /> <Badge text="Unused in Railway" variant="tip" />
4844

49-
Set this to `true` if Hollo is behind a reverse proxy. If you place the Hollo
45+
Set this to `true` if Hollo is behind a reverse proxy. If you place the Hollo
5046
behind an L7 load balancer (you usually should do this), turn this on.
5147

5248
Turned off by default.
5349

5450
<Aside>
5551
With this option, Hollo will trust the `X-Forwarded-For`, `X-Forwarded-Proto`,
56-
and `X-Forwarded-Host` headers from the reverse proxy. This is important for
52+
and `X-Forwarded-Host` headers from the reverse proxy. This is important for
5753
security reasons.
5854
</Aside>
5955

@@ -66,17 +62,15 @@ Turn on to test in local network.
6662
Turned off by default.
6763

6864
<Aside>
69-
Turning on this option is dangerous security-wise. Only use this option in
70-
a trusted environment and never in production.
65+
Turning on this option is dangerous security-wise. Only use this option in a
66+
trusted environment and never in production.
7167
</Aside>
7268

69+
## Additional features
7370

74-
Additional features
75-
-------------------
71+
### `HOME_URL` <Badge text="Optional" />
7672

77-
### `HOME_URL` <Badge text="Optional" />
78-
79-
If present, the home page will redirect to this URL. If not set, the home page
73+
If present, the home page will redirect to this URL. If not set, the home page
8074
will show the list of accounts on the instance.
8175

8276
### `REMOTE_ACTOR_FETCH_POSTS` <Badge text="Optional" />
@@ -90,7 +84,7 @@ encountered first time.
9084

9185
Setting this to `true` lets your timelines work like inboxes: all posts visible
9286
to your timeline are physically stored in the database, rather than being
93-
filtered in real-time as they are displayed. This is useful for relatively
87+
filtered in real-time as they are displayed. This is useful for relatively
9488
larger instances with many incoming posts.
9589

9690
As of Hollo 0.4.0, it is experimental and may have several bugs, but it is
@@ -101,19 +95,17 @@ Turned off by default.
10195
### `ALLOW_HTML` <Badge text="Optional" />
10296

10397
Setting this to `true` allows raw HTML inside Markdown, which is used for
104-
formatting posts, bio, etc. This is useful for allowing users to use broader
98+
formatting posts, bio, etc. This is useful for allowing users to use broader
10599
formatting options outside of Markdown, but to avoid XSS attacks, it is still
106100
limited to a subset of HTML tags and attributes.
107101

108102
Turned off by default.
109103

110-
111-
Logging and debugging
112-
---------------------
104+
## Logging and debugging
113105

114106
### `LOG_LEVEL` <Badge text="Optional" />
115107

116-
The log level for the application. `debug`, `info`, `warning`, `error`, and
108+
The log level for the application. `debug`, `info`, `warning`, `error`, and
117109
`fatal` are available.
118110

119111
`info` by default.
@@ -126,16 +118,14 @@ Turned off by default.
126118

127119
### `LOG_FILE` <Badge text="Optional" />
128120

129-
The path to the log file. Unlike console output, the log file is written in
121+
The path to the log file. Unlike console output, the log file is written in
130122
JSON Lines format which is suitable for structured logging.
131123

132124
### `SENTRY_DSN` <Badge text="Optional" />
133125

134126
The DSN of the Sentry project to send error reports and traces to.
135127

136-
137-
Asset storage
138-
-------------
128+
## Asset storage
139129

140130
### `DRIVE_DISK`
141131

@@ -154,9 +144,10 @@ See the [FlyDrive docs] for details about the drivers.
154144
production, existing files are not moved; only new files are stored according
155145
to the new settings.
156146

157-
Also, keep in mind that existing files will still be served according to the
158-
old settings, so if you change `S3_BUCKET`, for example, they will still be
159-
served from the old bucket and should not be deleted.
147+
Also, keep in mind that existing files will still be served according to the
148+
old settings, so if you change `S3_BUCKET`, for example, they will still be
149+
served from the old bucket and should not be deleted.
150+
160151
</Aside>
161152

162153
[FlyDrive docs]: https://flydrive.dev/docs/drive_manager
@@ -169,39 +160,38 @@ The path in the local filesystem where blob assets are stored, e.g.,
169160
`/var/lib/hollo`.
170161

171162
<Aside>
172-
- Directory must exist and be writable by the Hollo process.
173-
- Recommended permissions: 755 for directories, 644 for files.
174-
- Ensure sufficient storage capacity for your use case.
175-
- Regular backups are strongly recommended.
176-
- When using Docker, ensure the path is properly mounted.
163+
- Directory must exist and be writable by the Hollo process. - Recommended
164+
permissions: 755 for directories, 644 for files. - Ensure sufficient storage
165+
capacity for your use case. - Regular backups are strongly recommended. - When
166+
using Docker, ensure the path is properly mounted.
177167
</Aside>
178168

179169
### S3-compatible object storage settings
180170

181171
<Aside>
182172
These settings are only required when `DRIVE_DISK=s3`.
183173

184-
Ensure your AWS IAM policy grants the following permissions:
174+
Ensure your AWS IAM policy grants the following permissions:
185175

186-
- `s3:PutObject`
187-
- `s3:GetObject`
188-
- `s3:DeleteObject`
189-
- `s3:ListBucket`
190-
</Aside>
176+
- `s3:PutObject`
177+
- `s3:GetObject`
178+
- `s3:DeleteObject`
179+
- `s3:ListBucket`
180+
</Aside>
191181

192182
#### `ASSET_URL_BASE` <Badge text="Required with S3 driver" variant="caution" />
193183

194184
The public URL base of the asset storage, e.g.,
195185
`https://hollo.s3.us-east-1.amazonaws.com`.
196186

197187
<Aside type="caution">
198-
- HTTPS is required in production environments.
199-
- Must be publicly accessible for federation to work correctly.
188+
- HTTPS is required in production environments. - Must be publicly accessible
189+
for federation to work correctly.
200190
</Aside>
201191

202192
#### `S3_REGION` <Badge text="Required with S3 driver" variant="caution" />
203193

204-
The region of the S3-compatible object storage, e.g., `us-east-1`. On some
194+
The region of the S3-compatible object storage, e.g., `us-east-1`. On some
205195
non-S3 services, this can be omitted.
206196

207197
#### `S3_BUCKET` <Badge text="Required with S3 driver" variant="caution" />
@@ -215,8 +205,8 @@ The endpoint URL for S3-compatible object storage, e.g.,
215205

216206
#### `S3_FORCE_PATH_STYLE` <Badge text="Optional" />
217207

218-
Whether to force path-style URLs for S3-compatible object storage. `true` to
219-
turn on, `false` to turn off. Useful for non-AWS S3-compatible services.
208+
Whether to force path-style URLs for S3-compatible object storage. `true` to
209+
turn on, `false` to turn off. Useful for non-AWS S3-compatible services.
220210
Turned off by default.
221211

222212
#### `AWS_ACCESS_KEY_ID` <Badge text="Required with S3 driver" variant="caution" />

docs/src/content/docs/ja/install/env.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ Railwayのenvironment variablesメニューから設定できます。
1818

1919
サーバーが受信するポート番号。デフォルトは3000です。
2020

21-
### `HOST` <Badge text="オプション" /> <Badge text="Railwayでは使われない" variant="tip" />
21+
### `BIND` <Badge text="オプション" /> <Badge text="Railwayでは使われない" variant="tip" />
2222

2323
サーバーが受信するホストアドレス。有効なIPアドレスまたは`localhost`である必要があります。
2424

25-
デフォルトは`localhost`です。
26-
2725
### `DATABASE_URL` <Badge text="Railwayでは使われない" variant="tip" />
2826

2927
PostgreSQLのデータベースのURL。例:`postgresql://hollo:password@localhost/hollo`

docs/src/content/docs/ko/install/env.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ Railway의 environment variables 메뉴에서 설정할 수 있습니다.
1818

1919
서버가 수신할 포트 번호. 기본값은 3000입니다.
2020

21-
### `HOST` <Badge text="선택" /> <Badge text="Railway에서는 안 쓰임" variant="tip" />
21+
### `BIND` <Badge text="선택" /> <Badge text="Railway에서는 안 쓰임" variant="tip" />
2222

2323
서버가 수신할 호스트 주소. 유효한 IP 주소나 `localhost`여야 합니다.
2424

25-
기본값은 `localhost`입니다.
26-
2725
### `DATABASE_URL` <Badge text="Railway에서는 안 쓰임" variant="tip" />
2826

2927
PostgreSQL 데이터베이스의 URL. 예: `postgresql://hollo:password@localhost/hollo`.

docs/src/content/docs/zh-cn/install/env.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ Hollo是通过环境变量进行配置的。你可以在项目根目录的 *.env
1515

1616
服务器监听的端口号。默认为3000。
1717

18-
### `HOST` <Badge text="可选" /> <Badge text="Railway中未使用" variant="tip" />
18+
### `BIND` <Badge text="可选" /> <Badge text="Railway中未使用" variant="tip" />
1919

2020
服务器监听的主机地址。必须是有效的IP地址或`localhost`
2121

22-
默认是`localhost`
23-
2422
### `DATABASE_URL` <Badge text="Railway中未使用" variant="tip" />
2523

2624
PostgreSQL数据库的URL,例如:`postgresql://hollo:password@localhost/hollo`

0 commit comments

Comments
 (0)