all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup v2] fix #4095: make http client read proxy config from envvars
@ 2022-09-16  8:48 Stefan Hanreich
  2022-09-16 11:29 ` [pbs-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Hanreich @ 2022-09-16  8:48 UTC (permalink / raw)
  To: pbs-devel

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 <s.hanreich@proxmox.com>
---
 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@]<host>[: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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup v2] fix #4095: make http client read proxy config from envvars
  2022-09-16  8:48 [pbs-devel] [PATCH proxmox-backup v2] fix #4095: make http client read proxy config from envvars Stefan Hanreich
@ 2022-09-16 11:29 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2022-09-16 11:29 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Stefan Hanreich

Am 16/09/2022 um 10:48 schrieb Stefan Hanreich:
> 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 <s.hanreich@proxmox.com>
> ---
>  docs/backup-client.rst        | 11 +++++++++++
>  pbs-client/src/http_client.rs |  7 +++++++
>  2 files changed, 18 insertions(+)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-16 11:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16  8:48 [pbs-devel] [PATCH proxmox-backup v2] fix #4095: make http client read proxy config from envvars Stefan Hanreich
2022-09-16 11:29 ` [pbs-devel] applied: " Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal