mirror of
https://github.com/gethomepage/homepage.git
synced 2026-01-14 21:22:08 +08:00
Support HOMEPAGE_PROXY_DISABLE_IPV6
This commit is contained in:
@@ -27,6 +27,16 @@ You have a few options for deploying homepage, depending on your needs. We offer
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
|
||||||
### `HOMEPAGE_ALLOWED_HOSTS`
|
### `HOMEPAGE_ALLOWED_HOSTS`
|
||||||
|
|
||||||
As of v1.0 there is one required environment variable when deploying via a public URL, <code>HOMEPAGE_ALLOWED_HOSTS</code>. This is a comma separated (no spaces) list of allowed hosts (sometimes with the port) that can access your homepage. See the [docker](docker.md) and [source](source.md) installation pages for examples.
|
Required.
|
||||||
|
|
||||||
|
As of v1.0 there is one required environment variable when deploying via a public URL, <code>HOMEPAGE_ALLOWED_HOSTS</code>. This is a comma separated list of allowed hosts that can access your homepage. See the [docker](docker.md) and [source](source.md) installation pages for examples.
|
||||||
|
|
||||||
|
### `HOMEPAGE_PROXY_DISABLE_IPV6`
|
||||||
|
|
||||||
|
Optional.
|
||||||
|
|
||||||
|
In certain environments, you may need to disable IPv6 for the proxy to work correctly. Set this environment variable to `true` to disable IPv6.
|
||||||
|
|||||||
@@ -83,18 +83,18 @@ export function httpRequest(url, params) {
|
|||||||
|
|
||||||
export async function httpProxy(url, params = {}) {
|
export async function httpProxy(url, params = {}) {
|
||||||
const constructedUrl = new URL(url);
|
const constructedUrl = new URL(url);
|
||||||
|
const disableIpv6 = process.env.HOMEPAGE_PROXY_DISABLE_IPV6 === "true";
|
||||||
|
const agentOptions = disableIpv6 ? { family: 4, autoSelectFamily: false } : {};
|
||||||
|
|
||||||
let request = null;
|
let request = null;
|
||||||
if (constructedUrl.protocol === "https:") {
|
if (constructedUrl.protocol === "https:") {
|
||||||
request = httpsRequest(constructedUrl, {
|
request = httpsRequest(constructedUrl, {
|
||||||
agent: new https.Agent({
|
agent: new https.Agent({ ...agentOptions, rejectUnauthorized: false }),
|
||||||
rejectUnauthorized: false,
|
|
||||||
}),
|
|
||||||
...params,
|
...params,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
request = httpRequest(constructedUrl, {
|
request = httpRequest(constructedUrl, {
|
||||||
agent: new http.Agent(),
|
agent: new http.Agent(agentOptions),
|
||||||
...params,
|
...params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user