From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 1D90393355 for ; Fri, 16 Sep 2022 10:48:41 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 12D772186B for ; Fri, 16 Sep 2022 10:48:41 +0200 (CEST) Received: from lana.proxmox.com (unknown [94.136.29.99]) by firstgate.proxmox.com (Proxmox) with ESMTP for ; Fri, 16 Sep 2022 10:48:40 +0200 (CEST) Received: by lana.proxmox.com (Postfix, from userid 10043) id 5ADA92C20B0; Fri, 16 Sep 2022 10:48:40 +0200 (CEST) From: Stefan Hanreich To: pbs-devel@lists.proxmox.com Date: Fri, 16 Sep 2022 10:48:38 +0200 Message-Id: <20220916084838.1149689-1-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.305 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods NO_DNS_FOR_FROM 0.001 Envelope sender has no MX or A DNS records RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pbs-devel] [PATCH proxmox-backup v2] fix #4095: make http client read proxy config from envvars X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Sep 2022 08:48:41 -0000 In order to be able to use a proxy with the proxmox-backup-client, use ProxyConfig for parsing proxy server config from the environment. Also added a section in the documentation that describes how to configure the environment if a proxy server should be used. Signed-off-by: Stefan Hanreich --- docs/backup-client.rst | 11 +++++++++++ pbs-client/src/http_client.rs | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/docs/backup-client.rst b/docs/backup-client.rst index cc56d17e..f5cbbf67 100644 --- a/docs/backup-client.rst +++ b/docs/backup-client.rst @@ -69,6 +69,17 @@ Environment Variables When set, this value is used to verify the server certificate (only used if the system CA certificates cannot validate the certificate). +``ALL_PROXY`` + When set, the client uses the specified HTTP proxy for all connections to the + backup server. Currently only HTTP proxies are supported. Valid proxy + configurations have the following format: + `[http://][user:password@][:port]`. Default `port` is 1080, if not + otherwise specified. + + +.. Note:: The recommended solution for shielding hosts is using tunnels such as + wireguard, instead of using an HTTP proxy. + .. Note:: Passwords must be valid UTF-8 and may not contain newlines. For your convenience, Proxmox Backup Server only uses the first line as password, so diff --git a/pbs-client/src/http_client.rs b/pbs-client/src/http_client.rs index 4ef1350b..491b603b 100644 --- a/pbs-client/src/http_client.rs +++ b/pbs-client/src/http_client.rs @@ -23,6 +23,7 @@ use proxmox_sys::linux::tty; use proxmox_async::broadcast_future::BroadcastFuture; use proxmox_http::client::{HttpsConnector, RateLimiter}; +use proxmox_http::ProxyConfig; use proxmox_http::uri::{build_authority, json_object_to_query}; use pbs_api_types::percent_encoding::DEFAULT_ENCODE_SET; @@ -389,6 +390,12 @@ impl HttpClient { ))))); } + let proxy_config = ProxyConfig::from_proxy_env()?; + if let Some(config) = proxy_config { + log::info!("Using proxy connection: {}:{}", config.host, config.port); + https.set_proxy(config); + } + let client = Client::builder() //.http2_initial_stream_window_size( (1 << 31) - 2) //.http2_initial_connection_window_size( (1 << 31) - 2) -- 2.30.2