mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat(server): add IP trust list for reverse proxy (#11286)
* feat(server): add IP trust list for reverse proxy Signed-off-by: hitech95 <nicveronese@gmail.com> * feat(docs): add documentation of `IMMICH_TRUSTED_PROXIES` env Signed-off-by: hitech95 <nicveronese@gmail.com> --------- Signed-off-by: hitech95 <nicveronese@gmail.com>
This commit is contained in:
parent
ea5d6780f2
commit
a3799b3053
3 changed files with 26 additions and 2 deletions
|
|
@ -14,9 +14,18 @@ import { useSwagger } from 'src/utils/misc';
|
|||
|
||||
const host = process.env.HOST;
|
||||
|
||||
function parseTrustedProxy(input?: string) {
|
||||
if (!input) {
|
||||
return [];
|
||||
}
|
||||
// Split on ',' char to allow multiple IPs
|
||||
return input.split(',');
|
||||
}
|
||||
|
||||
async function bootstrap() {
|
||||
process.title = 'immich-api';
|
||||
const otelPort = Number.parseInt(process.env.IMMICH_API_METRICS_PORT ?? '8081');
|
||||
const trustedProxies = parseTrustedProxy(process.env.IMMICH_TRUSTED_PROXIES ?? '');
|
||||
|
||||
otelStart(otelPort);
|
||||
|
||||
|
|
@ -27,7 +36,7 @@ async function bootstrap() {
|
|||
logger.setAppName('Api');
|
||||
logger.setContext('Bootstrap');
|
||||
app.useLogger(logger);
|
||||
app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']);
|
||||
app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal', ...trustedProxies]);
|
||||
app.set('etag', 'strong');
|
||||
app.use(cookieParser());
|
||||
app.use(json({ limit: '10mb' }));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue