Skip to content

Commit

Permalink
fix: allow to set a custom trust proxy value
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Jan 22, 2024
1 parent 3035d65 commit b1a34df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,11 @@ function sortStore(store: StoreFileEntry[]) {
logger.info(`Version: ${utils.getVersion()}`)
logger.info('Application path:' + utils.getPath(true))

if (process.env.TRUST_PROXY === 'true') {
// ensure the server sees the real client ip even behind a proxy (eg. for rate limiting or authentication checks)
app.set('trust proxy', true)
if (process.env.TRUST_PROXY) {
app.set(
'trust proxy',
process.env.TRUST_PROXY === 'true' ? true : process.env.TRUST_PROXY,
)
}

app.use(
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/env-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This is the list of the supported environment variables:
- `ZUI_LOG_MAXSIZE`: The maximum size of a single log file. Default is `50m` (50MB)
- `NO_LOG_COLORS`: Set this env var to `'true'` to disable application log colors also in the console.
- `ZUI_NO_CONSOLE`: Set this env var to `'true'` to disable application log in the console.
- `TRUST_PROXY`: Set this env var to `'true'` to trust the proxy and get the client IP from `X-Forwarded-For` header.
- `TRUST_PROXY`: Set this env in order to trust the proxy. See [express behind proxies](https://expressjs.com/en/guide/behind-proxies.html) for more info about allowed values.
- `FORCE_DISABLE_SSL`: Set this env var to `'true'` to disable SSL.
- `BASE_PATH`: Set this env var to the base path where the application is served. Default is `/`.
- `UID_DISCOVERY_PREFIX`: Sets the prefix used for MQTT Discovery `unique_id` of entities. Default is `zwavejs2mqtt_`.
Expand Down

0 comments on commit b1a34df

Please sign in to comment.