Skip to content

Commit 1ed2f16

Browse files
authored
Enhancement: improve dual-stack support (gethomepage#6070)
1 parent ba2b3ee commit 1ed2f16

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ RUN apk add --no-cache su-exec iputils-ping shadow
5454
USER root
5555

5656
ENV NODE_ENV=production
57-
ENV HOSTNAME=0.0.0.0
57+
ENV HOSTNAME=::
5858
ENV PORT=3000
5959
EXPOSE $PORT
6060

docker-entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ export PGID=${PGID:-0}
1212

1313
export HOMEPAGE_BUILDTIME=$(date +%s)
1414

15+
# Try IPv6 first (dual stack when available), but fall back to IPv4 if the bind fails
16+
export HOSTNAME=${HOSTNAME:-::}
17+
if [ "$HOSTNAME" = "::" ]; then
18+
if ! node -e "const server = require('http').createServer(() => {}); const host = '::'; const port = process.env.PORT || 3000; server.once('error', (err) => { console.error('IPv6 bind failed:', err.message); process.exit(1); }); server.listen(port, host, () => server.close(() => process.exit(0)));"; then
19+
echo "Falling back to IPv4 bind at 0.0.0.0"
20+
export HOSTNAME=0.0.0.0
21+
fi
22+
fi
23+
1524
# Check ownership before chown
1625
if [ -e /app/config ]; then
1726
CURRENT_UID=$(stat -c %u /app/config)

docs/troubleshooting/index.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,6 @@ All service widgets work essentially the same, that is, homepage makes a proxied
6868
6969
If, after correctly adding and mapping your custom icons via the [Icons](../configs/services.md#icons) instructions, you are still unable to see your icons please try recreating your container.
7070
71-
## Enabling IPv6 for the homepage container
72-
73-
To enable IPv6 support for the homepage container, you can set the `HOSTNAME` environment variable, for example:
74-
75-
```yaml
76-
services:
77-
homepage:
78-
...
79-
environment:
80-
- HOSTNAME=::
81-
```
82-
8371
## Disabling IPv6 for http requests {#disabling-ipv6}
8472
8573
If you are having issues with certain widgets that are unable to reach public APIs (e.g. weather), in certain setups you may need to disable IPv6. You can set the environment variable `HOMEPAGE_PROXY_DISABLE_IPV6` to `true` to disable IPv6 for the homepage proxy.

src/middleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function middleware(req) {
44
// Check the Host header, if HOMEPAGE_ALLOWED_HOSTS is set
55
const host = req.headers.get("host");
66
const port = process.env.PORT || 3000;
7-
let allowedHosts = [`localhost:${port}`, `127.0.0.1:${port}`];
7+
let allowedHosts = [`localhost:${port}`, `127.0.0.1:${port}`, `[::1]:${port}`];
88
const allowAll = process.env.HOMEPAGE_ALLOWED_HOSTS === "*";
99
if (process.env.HOMEPAGE_ALLOWED_HOSTS) {
1010
allowedHosts = allowedHosts.concat(process.env.HOMEPAGE_ALLOWED_HOSTS.split(","));

0 commit comments

Comments
 (0)