[pve-devel] [PATCH cluster 1/3] datacenter config: add setting for HTTP{, S} proxies
    Maximiliano Sandoval 
    m.sandoval at proxmox.com
       
    Tue Oct 21 12:03:25 CEST 2025
    
    
  
Adds a 'proxy' setting which is meant to replace 'http_proxy'. This new
setting allows to specify different HTTP and HTTPS proxies for different
pieces of the stack.
In the UI each option would set both the HTTP and HTTPS proxies together
to the same value to avoid configuration mistakes, e.g. if only one
proxy is set.
The use-case this option intends to cover is a proxy which allows to
proxy HTTP(S) requests to the outside but will reject any connection to
resources which are already in the internal network, for this cases the
'none' option would declare that no proxy should be used.
The {proxy}->{global} default key of the property string acts as a
drop-in replacement for the {http_proxy} setting. However, we document
that this will be used both as a HTTP and a HTTPS proxy which was not
done always for the 'http_proxy' setting.
Individual proxy configurations accept a 'none' value that allows to say
that no proxy should be used for this use-case, this takes precedence
over both the new global proxy and the 'http_proxy'.
Subscriptions only need HTTPS proxies and thus we do not offer the
option to setup a HTTP proxy here.
Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
 src/PVE/DataCenterConfig.pm | 60 +++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
diff --git a/src/PVE/DataCenterConfig.pm b/src/PVE/DataCenterConfig.pm
index c6d56c1..57c5c1c 100644
--- a/src/PVE/DataCenterConfig.pm
+++ b/src/PVE/DataCenterConfig.pm
@@ -120,6 +120,52 @@ my $notification_format = {
     },
 };
 
+my $proxy_format = {
+    'global' => {
+        default_key => 1,
+        optional => 1,
+        type => 'string',
+        description => "Proxy used as a fallback. It will be used when the respective component does not have a proxy defined. Will be used both as a HTTP and HTTPS proxies.",
+        pattern => "http://.*",
+        format_description => 'URL',
+    },
+    'http-download' => {
+        optional => 1,
+        type => 'string',
+        description => "HTTP proxy used for downloading ISOs and container templates. When set to 'none' no proxy will be used.",
+        pattern => "(http://.*|none)",
+        format_description => 'URL',
+    },
+    'https-download' => {
+        optional => 1,
+        description => "HTTPS proxy used for downloading ISOs and container templates. When set to 'none' no proxy will be used.",
+        type => 'string',
+        pattern => "(http://.*|none)",
+        format_description => 'URL',
+    },
+    'https-subscription' => {
+        optional => 1,
+        description => "HTTPS proxy used for subscription related tasks. When set to 'none' no proxy will be used.",
+        type => 'string',
+        pattern => "(http://.*|none)",
+        format_description => 'URL',
+    },
+    'http-apt' => {
+        optional => 1,
+        description => "HTTP proxy used for APT. When set to 'none' no proxy will be used.",
+        type => 'string',
+        pattern => "(http://.*|none)",
+        format_description => 'URL',
+    },
+    'https-apt' => {
+        optional => 1,
+        description => "HTTPS proxy used for APT. When set to 'none' no proxy will be used.",
+        type => 'string',
+        pattern => "(http://.*|none)",
+        format_description => 'URL',
+    },
+};
+
 register_standard_option(
     'pve-ha-shutdown-policy',
     {
@@ -352,6 +398,12 @@ my $datacenter_schema = {
                 "Specify external http proxy which is used for downloads (example: 'http://username:password\@host:port/')",
             pattern => "http://.*",
         },
+        proxy => {
+            optional => 1,
+            type => 'string',
+            description => "Settings for declaring HTTP and HTTPS proxies for individual components. When a specific proxy is not specied 'http_proxy' will be used instead.",
+            format => $proxy_format,
+        },
         # FIXME: remove with 8.0 (add check to pve7to8!), merged into "migration" since 4.3
         migration_unsecure => {
             optional => 1,
@@ -536,6 +588,10 @@ sub parse_datacenter_config {
         $res->{replication} = parse_property_string($replication_format, $replication);
     }
 
+    if (my $proxy = $res->{proxy}) {
+        $res->{proxy} = parse_property_string($proxy_format, $proxy);
+    }
+
     if (my $next_id = $res->{'next-id'}) {
         $res->{'next-id'} = parse_property_string($next_id_format, $next_id);
     }
@@ -619,6 +675,10 @@ sub write_datacenter_config {
         $cfg->{replication} = PVE::JSONSchema::print_property_string($replication, $replication_format);
     }
 
+    if (ref(my $proxy = $cfg->{proxy})) {
+        $cfg->{proxy} = PVE::JSONSchema::print_property_string($proxy, $proxy_format);
+    }
+
     if (defined(my $next_id = $cfg->{'next-id'})) {
         $next_id = parse_property_string($next_id_format, $next_id) if !ref($next_id);
 
-- 
2.47.3
    
    
More information about the pve-devel
mailing list