feat: Support x-forwarded-for headers for IPs (#4684)

* feat: Support x-forwarded-for headers for IPs

Fixes #4430.

* Fix realip accepting headers

* Fix unused headers
This commit is contained in:
Kyle Carberry
2022-10-23 13:21:49 -05:00
committed by GitHub
parent 795ed3dc97
commit f75a54cd1e
15 changed files with 946 additions and 23 deletions
+10
View File
@@ -113,6 +113,16 @@ func newConfig() codersdk.DeploymentConfig {
Flag: "pprof-address",
Value: "127.0.0.1:6060",
},
ProxyTrustedHeaders: codersdk.DeploymentConfigField[[]string]{
Key: "proxy.trusted_headers",
Flag: "proxy-trusted-headers",
Usage: "Headers to trust for forwarding IP addresses. e.g. Cf-Connecting-IP True-Client-Ip, X-Forwarded-for",
},
ProxyTrustedOrigins: codersdk.DeploymentConfigField[[]string]{
Key: "proxy.trusted_origins",
Flag: "proxy-trusted-origins",
Usage: "Origin addresses to respect \"proxy-trusted-headers\". e.g. example.com",
},
CacheDirectory: codersdk.DeploymentConfigField[string]{
Key: "cache_directory",
Usage: "The directory to cache temporary files. If unspecified and $CACHE_DIRECTORY is set, it will be used for compatibility with systemd.",