mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
feat: Add support for configurable proxy IP header in environment settings (#11595)
* feat: Add support for configurable proxy IP header in environment settings * Update server/env.ts Remove mention of Koa from docs Co-authored-by: Tom Moor <tom.moor@gmail.com> * Update .env.sample Remove mention of Koa from env sample. Co-authored-by: Tom Moor <tom.moor@gmail.com> --------- Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
@@ -119,6 +119,11 @@ SSL_CERT=
|
||||
# false if you can be sure that SSL is terminated at an external loadbalancer.
|
||||
FORCE_HTTPS=true
|
||||
|
||||
# When behind a reverse proxy, the header to use for the client IP.
|
||||
# The default value is "X-Forwarded-For", common values are "X-Real-IP"
|
||||
# and "X-Client-IP".
|
||||
# PROXY_IP_HEADER=
|
||||
|
||||
|
||||
# ––––––––––––––––––––––––––––––––––––––
|
||||
# –––––––––– AUTHENTICATION ––––––––––
|
||||
|
||||
@@ -341,6 +341,16 @@ export class Environment {
|
||||
@IsBoolean()
|
||||
public FORCE_HTTPS = this.toBoolean(environment.FORCE_HTTPS ?? "true");
|
||||
|
||||
/**
|
||||
* When the app is behind a proxy, sets the HTTP header used for the client IP.
|
||||
* The default value is "X-Forwarded-For", common values are "X-Real-IP"
|
||||
* and "X-Client-IP".
|
||||
*/
|
||||
@IsOptional()
|
||||
public PROXY_IP_HEADER = this.toOptionalString(
|
||||
environment.PROXY_IP_HEADER
|
||||
);
|
||||
|
||||
/**
|
||||
* Should the installation send anonymized statistics to the maintainers.
|
||||
* Defaults to true.
|
||||
|
||||
@@ -47,6 +47,9 @@ export default function init(app: Koa = new Koa(), server?: Server) {
|
||||
|
||||
// trust header fields set by our proxy. eg X-Forwarded-For
|
||||
app.proxy = true;
|
||||
if (env.PROXY_IP_HEADER) {
|
||||
app.proxyIpHeader = env.PROXY_IP_HEADER;
|
||||
}
|
||||
}
|
||||
|
||||
// Make `ctx.userAgent` available
|
||||
|
||||
Reference in New Issue
Block a user