Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

fix(backend:config): deprecate numeric `trustProxy` values and map them to booleans

johaven1b922e1e5b1c
diff --git a/backend/src/configuration/config.environment.ts b/backend/src/configuration/config.environment.ts
index 23c74a7a..4bb2e98d 100755
--- a/backend/src/configuration/config.environment.ts
+++ b/backend/src/configuration/config.environment.ts
@@ -55,6 +55,7 @@ function loadConfiguration(): GlobalConfig {
config.applications.files.spacesPath = join(config.applications.files.dataPath, 'spaces')
config.applications.files.linksPath = join(config.applications.files.dataPath, 'links')
// DEPRECATIONS
+ deprecatedServerTrustProxyConfig(config)
deprecatedFilesEditorsConfig(config)
deprecatedFilesContentIndexingConfig(config)
@@ -93,6 +94,17 @@ function deprecatedFilesEditorsEnvConfig(): void {
}
}
+function deprecatedServerTrustProxyConfig(config: GlobalConfig): void {
+ if (typeof config.server?.trustProxy !== 'number') {
+ return
+ }
+
+ console.warn(
+ '[DEPRECATED][CONFIGURATION] Numeric server.trustProxy values will be removed in the next major version. ' +
+ 'They now map to booleans (>= 1: true, < 1: false); use true/false or a trusted proxy IP/CIDR instead.'
+ )
+}
+
function deprecatedFilesEditorsConfig(config: GlobalConfig): void {
const files = config.applications.files as unknown as Record<string, any>
const legacyEditors = ['onlyoffice', 'collabora'].filter((editor) => Object.prototype.hasOwnProperty.call(files, editor))
diff --git a/backend/src/configuration/config.validation.ts b/backend/src/configuration/config.validation.ts
index 1281e360..42e925f4 100644
--- a/backend/src/configuration/config.validation.ts
+++ b/backend/src/configuration/config.validation.ts
@@ -50,8 +50,10 @@ export class ServerConfig {
@Min(1)
workers: number = 1
+ // Temporary compatibility for deprecated numeric hop counts.
+ @Transform(({ value }) => (typeof value === 'number' ? value >= 1 : value))
@IsOptional()
- trustProxy: boolean | string | number = 1
+ trustProxy: boolean | string = true
@IsBoolean()
restartOnFailure: boolean = true
diff --git a/environment/environment.dist.yaml b/environment/environment.dist.yaml
index 6e2a0ca5..147c3339 100644
--- a/environment/environment.dist.yaml
+++ b/environment/environment.dist.yaml
@@ -12,9 +12,10 @@ server:
# workers: `auto` or `0` (use all cpus) | number of CPUs to use
# default: 1
workers: 1
- # trust proxy: number (trust the nth hop from the front-facing proxy server as the client) | `true` | `false` | `127.0.0.1,192.168.1.1/24`
- # default: 1
- trustProxy: 1
+ # trust proxy: `true` (trust all proxies) | `false` | `127.0.0.1,192.168.1.1/24`
+ # legacy numeric values >= 1 are treated as `true` for compatibility
+ # default: true
+ trustProxy: true
# restartOnFailure: automatically restart workers if they are killed or die
# default: `true`
restartOnFailure: true