Skip to content

Commit 1c47fc2

Browse files
committed
feat: Add IP_RANGES_FETCH_ENABLED environment variable
This change adds a new environment variable to control whether IP ranges are fetched during application startup. When set to 'false', the initial fetch will be skipped, which can: 1. Speed up application startup 2. Avoid connectivity issues in environments with restricted internet access 3. Prevent startup failures when CloudFront or CloudFlare services are unreachable
1 parent 79d28f0 commit 1c47fc2

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

backend/index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
const schema = require('./schema');
44
const logger = require('./logger').global;
55

6+
const IP_RANGES_FETCH_ENABLED = process.env.IP_RANGES_FETCH_ENABLED !== 'false';
7+
68
async function appStart () {
79
const migrate = require('./migrate');
810
const setup = require('./setup');
@@ -13,7 +15,18 @@ async function appStart () {
1315
return migrate.latest()
1416
.then(setup)
1517
.then(schema.getCompiledSchema)
16-
.then(internalIpRanges.fetch)
18+
.then(() => {
19+
if (IP_RANGES_FETCH_ENABLED) {
20+
logger.info('IP Ranges fetch is enabled');
21+
return internalIpRanges.fetch().catch(err => {
22+
logger.error('IP Ranges fetch failed, continuing anyway:', err.message);
23+
return Promise.resolve();
24+
});
25+
} else {
26+
logger.info('IP Ranges fetch is disabled by environment variable');
27+
return Promise.resolve();
28+
}
29+
})
1730
.then(() => {
1831
internalCertificate.initTimer();
1932
internalIpRanges.initTimer();

docs/src/advanced-config/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ The easy fix is to add a Docker environment variable to the Nginx Proxy Manager
161161
DISABLE_IPV6: 'true'
162162
```
163163

164+
## Disabling IP Ranges Fetch
165+
166+
By default, NPM fetches IP ranges from CloudFront and Cloudflare during application startup. In environments with limited internet access or to speed up container startup, this fetch can be disabled:
167+
168+
```yml
169+
environment:
170+
IP_RANGES_FETCH_ENABLED: 'false'
171+
```
164172

165173
## Custom Nginx Configurations
166174

0 commit comments

Comments
 (0)