Come configurare il proxy in Windows

Panoramica

Questa guida spiega come configurare il proxy in Windows, distinguendo tra impostazioni per utente (WinINET) e impostazioni per l’intero sistema (WinHTTP).
Esempio: ProxyServer = http=<<PROXY_ADDRESS>>;https=<<PROXY_ADDRESS>>
I valori dipendenti dall’ambiente sono indicati come <<variabile>>.


Convenzioni delle variabili

Variabile Esempio Descrizione
<<PROXY_ADDRESS>> proxy.example.com:8080 Host e porta del server proxy
<<PROXY_BYPASS>> intranet.example.com;192.168.*;<local> Domini o subnet escluse dal proxy; separare con ;
<<ADVPROXY_SETTINGS_PATH>> C:\proxy-settings.json Percorso del file di configurazione per advproxy

Step 1: Tipi di configurazione proxy in Windows

Tipo Ambito Utilizzo
Utente (WinINET) Account utente loggato Browser e applicazioni dell’utente; riflette le impostazioni di IE/Edge
Sistema (WinHTTP) Servizi e sistema operativo Necessario per Windows Update, BITS, Microsoft Defender, ecc.

BITS (Background Intelligent Transfer Service) gestisce i trasferimenti in background, come aggiornamenti di Windows o Defender.
Poiché opera come LocalSystem, le impostazioni proxy utente (WinINET) non si applicano.


Step 2: Impostare il proxy per utente (WinINET) tramite PowerShell

$proxy = "<<PROXY_ADDRESS>>"
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" `
  -Name ProxyEnable -Value 1
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" `
  -Name ProxyServer -Value "http=$proxy;https=$proxy"
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" `
  -Name ProxyOverride -Value "<<PROXY_BYPASS>>"

Verifica:

Get-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | Select ProxyEnable, ProxyServer, ProxyOverride

Step 3: Impostare il proxy di sistema (WinHTTP / BITS)

① Metodo legacy (Windows Server 2019 o precedente)

netsh winhttp set proxy <<PROXY_ADDRESS>> "<<PROXY_BYPASS>>"
netsh winhttp show proxy

② Metodo moderno (Windows Server 2022 e successivi – consigliato)

Crea un file JSON:

@'
{
  "ProxyIsEnabled": true,
  "Proxy": "http=<<PROXY_ADDRESS>>;https=<<PROXY_ADDRESS>>",
  "ProxyBypass": "<<PROXY_BYPASS>>",
  "AutoConfigIsEnabled": false,
  "AutoDetect": false
}
'@ | Out-File "<<ADVPROXY_SETTINGS_PATH>>" -Encoding ascii

Applica le impostazioni:

netsh winhttp set advproxy setting-scope=machine settings-file="<<ADVPROXY_SETTINGS_PATH>>"

In alternativa, è possibile applicare direttamente le impostazioni senza creare il file JSON:

netsh winhttp set advproxy setting-scope=machine settings='{\"ProxyIsEnabled\":true,\"Proxy\":\"http=<<PROXY_ADDRESS>>;https=<<PROXY_ADDRESS>>\",\"ProxyBypass\":\"<<PROXY_BYPASS>>\",\"AutoConfigIsEnabled\":false,\"AutoDetect\":false}'

Questa opzione è utile per test rapidi o ambienti temporanei.


Step 4: Applicare il proxy BITS per l’account di sistema

bitsadmin /util /setieproxy localsystem MANUAL_PROXY <<PROXY_ADDRESS>> "<<PROXY_BYPASS>>"
bitsadmin /util /getieproxy localsystem

Step 5: Verifica e risoluzione dei problemi

netsh winhttp show proxy
Get-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | Select ProxyEnable, ProxyServer, ProxyOverride

Se Windows Update fallisce dietro proxy, disattiva AutoDetect e utilizza il formato advproxy per ambienti Server Core.


Ripristinare le impostazioni proxy

Utente (WinINET)

Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyEnable -Value 0
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyServer -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyOverride -ErrorAction SilentlyContinue

Sistema (WinHTTP / advproxy)

netsh winhttp reset proxy

Oppure, per Windows Server 2022 e successivi:

netsh winhttp set advproxy setting-scope=machine settings='{\"Proxy\":\"\",\"ProxyBypass\":\"\",\"AutoconfigUrl\":\"\",\"AutoDetect\":false}'

Conclusione

In Windows esistono due livelli di configurazione proxy principali:

  • WinINET: per browser e applicazioni utente.
  • WinHTTP / advproxy: per servizi di sistema come Windows Update o BITS.

Per ambienti moderni, l’uso di advproxy è raccomandato.
Conoscere il contesto (utente o sistema) e applicare la configurazione corretta garantisce stabilità delle comunicazioni anche dietro proxy aziendali.