Skip to content

Commit 6625bc7

Browse files
CopilotMihaZupan
andauthored
Document UseProxy configuration for default system proxy in YARP (#36288)
* Initial plan * Add documentation for using default system proxy with UseProxy = true Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com> * Fix missing semicolons in code examples Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
1 parent 748aa64 commit 6625bc7

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

aspnetcore/fundamentals/servers/yarp/http-client-config.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: YARP HTTP Client Configuration
44
description: YARP HTTP Client Configuration
55
author: wadepickett
66
ms.author: wpickett
7-
ms.date: 2/6/2025
7+
ms.date: 11/01/2025
88
ms.topic: article
99
content_well_notification: AI-contribution
1010
ai-usage: ai-assisted
@@ -94,6 +94,9 @@ builder.WebHost.ConfigureKestrel(kestrel =>
9494
}
9595
```
9696

97+
> [!NOTE]
98+
> The default `ForwarderHttpClientFactory` sets `UseProxy` to `false`. If you want to use the default system proxy instead of specifying a custom proxy address, you can set `UseProxy` back to `true` using the `ConfigureHttpClient` method. This is useful when debugging with tools like Fiddler. See the [Configuring the http client](#configuring-the-http-client) section for an example.
99+
97100
### HttpRequest
98101
HTTP request configuration is based on [ForwarderRequestConfig](xref:Yarp.ReverseProxy.Forwarder.ForwarderRequestConfig) and represented by the following configuration schema.
99102
```json
@@ -206,9 +209,23 @@ services.AddReverseProxy()
206209
.ConfigureHttpClient((context, handler) =>
207210
{
208211
handler.SslOptions.ClientCertificates.Add(clientCert);
209-
})
212+
});
213+
```
214+
215+
### Using the default system proxy
216+
217+
The default `ForwarderHttpClientFactory` sets `UseProxy` to `false` to avoid the overhead of proxy detection and configuration. If you need to use the default system proxy (for example, when debugging with Fiddler or other proxy tools), you can set `UseProxy` back to `true`:
218+
219+
```csharp
220+
services.AddReverseProxy()
221+
.ConfigureHttpClient((context, handler) =>
222+
{
223+
handler.UseProxy = true;
224+
});
210225
```
211226

227+
This configuration allows the `HttpClient` to use the system's default proxy settings without having to manually specify a proxy address in the `WebProxy` configuration.
228+
212229
## Custom IForwarderHttpClientFactory
213230
If direct control of HTTP client construction is necessary, the default [IForwarderHttpClientFactory](xref:Yarp.ReverseProxy.Forwarder.IForwarderHttpClientFactory) can be replaced with a custom one. For some customizations you can derive from the default [ForwarderHttpClientFactory](xref:Yarp.ReverseProxy.Forwarder.ForwarderHttpClientFactory) and override the methods that configure the client.
214231

0 commit comments

Comments
 (0)