mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-14 12:46:49 +00:00
feat: Introduce accepted_ip_sources as a multiple options variant of request_ip_source
The current `request_ip_source` setting only allows a single option. While it does fall back to the peer IP if the header is missing as of !2003, which likely covers a lot of regular use, only allowing a single option limits the deployment options available to more advanced deployments. Setups where internal and external traffic use different reverse proxies will end up with the wrong IP and the implicitness of the fallback allows for situations where the used IP is not the IP expected. By introducing a setting that allows multiple options to be set, this limitation is resolved and it becomes possible to have client IP resolution behind different reverse proxies and also making it possible to decide if and/or what the fallback should be. If set, options are evaluated in order. If all fail, the request fails.
This commit is contained in:
1 parent
480e975877
commit
b9c6d5956f
9 files changed
+244
-132
No files matched your search
+35
-2
@@ -370,7 +370,7 @@ pub struct Config {
|
||||
#[serde(default = "default_ip_lookup_strategy")]
|
||||
pub ip_lookup_strategy: u8,
|
||||
|
||||
/// The source to use for discovering the real connecting client IP.
|
||||
/// The preferred source to use for getting the real client IP.
|
||||
///
|
||||
/// Takes any of the following options:
|
||||
///
|
||||
@@ -381,16 +381,49 @@ pub struct Config {
|
||||
/// "true_client_ip" - `True-Client-Ip` header
|
||||
/// "x_envoy_external_address" - `X-Envoy-External-Address` header
|
||||
/// "x_real_ip" - `X-Real-Ip` header
|
||||
/// "direct" - the directly connected IP address (fallback for other
|
||||
/// options)
|
||||
///
|
||||
/// Only set this if you are certain only your reverse proxy
|
||||
/// will send the expected header. There is no "is the connecting IP allowed
|
||||
/// to set this header" check; if the header selected is present, it is
|
||||
/// used.
|
||||
///
|
||||
/// Defaults to the IP address actually making the connection.
|
||||
/// Ignored if `accepted_ip_sources` is set.
|
||||
///
|
||||
/// If not set set, `direct` is used. Additionally, `direct` is used
|
||||
/// as a fallback if the chosen header is not found.
|
||||
#[serde(default)]
|
||||
pub request_ip_source: Option<String>,
|
||||
|
||||
/// The accepted source(s) for the real client IP.
|
||||
///
|
||||
/// Takes any combination of the following options:
|
||||
///
|
||||
/// "cf_connecting_ip" - `Cf-Connecting-Ip` header
|
||||
/// "cloudfront_viewer_address" - `CloudFront-Viewer-Address` header
|
||||
/// "fly_client_ip" - `Fly-Client-IP` header
|
||||
/// "x_forwarded_for" - rightmost value of the `X-Forwarded-For` header
|
||||
/// "true_client_ip" - `True-Client-Ip` header
|
||||
/// "x_envoy_external_address" - `X-Envoy-External-Address` header
|
||||
/// "x_real_ip" - `X-Real-Ip` header
|
||||
/// "direct" - the directly connected IP address
|
||||
///
|
||||
/// Only set this if you are certain only your reverse proxy
|
||||
/// will send the expected header. There is no "is the connecting IP allowed
|
||||
/// to set this header" check; if the header selected is present, it is
|
||||
/// used.
|
||||
///
|
||||
/// One of the configured sources must be available or the request is
|
||||
/// rejected. If you want a fallback (including `direct`!), you have to
|
||||
/// configure it. Priority is based on configuration order.
|
||||
///
|
||||
/// If not set, `request_ip_source` configuration is used.
|
||||
///
|
||||
/// default: []
|
||||
#[serde(default)]
|
||||
pub accepted_ip_sources: Vec<String>,
|
||||
|
||||
/// Max request size for file uploads in bytes. Defaults to 20MB.
|
||||
/// Also limits incoming federated media.
|
||||
///
|
||||
|
||||
Reference in new issue
Block a user