question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[core] allow programmatic configuration of no proxy list

See original GitHub issue

One problem with current approach is that we load the noProxyList from NO_PROXY env var and cache it in first proxyPolicy() call, therefore

  • it is not possible to change the list when creating new pipelines.
  • it is not easy to configure noProxyList programmatically. For example, storage explorer allow users to configure proxy settings from the UI instead of using the NO_PROXY environment variable.

To address 1) we should remove the caching and load the list every time proxyPolicy() is called.

For 2) maybe add a parameter for noProxyList?

export function proxyPolicy(proxySettings?: ProxySettings, customNoProxyList?: string[]): RequestPolicyFactory {
  if (!proxySettings) {
    proxySettings = getDefaultProxySettings();
  }
  noProxyList = customNoProxyList ?? loadNoProxy();

  return {
    create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => {
      return new ProxyPolicy(nextPolicy, options, proxySettings!);
    }
  };
}

Another question is do we want to make noProxyList per ProxyPolicy, similar to proxySettings? There might be case where two clients from different SDK libraries want to use different set of proxy configurations. This will then make the noProxyList and the byPassedList cache per ProxyPolicy

@bterlson @chradek @xirzec

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
craxalcommented, Jul 13, 2021

Storage Explorer is currently in the process of adding direct support for NO_PROXY.

Storage Explorer allows users to specify proxy settings using either system proxy settings, custom app proxy settings, or environment variables. Users can change these settings at any time, which means we need to be able to support changing proxy information used by the various networking modules we use (request, Azure SDK, etc.). This is further complicated by the fact that Storage Explorer is spread out across several processes. Relying on environment variables for proxy settings is not sufficient without a full app restart.

Here’s how we intend to handle environment variables in 1.21.0:

  1. At startup, copy the environment variables to an internal object. If the user wishes to use proxy settings from environment variables, this object becomes the source for this information.
  2. Delete the environment variables before any networking modules have a chance to load and read them.
  3. When the user changes any proxy settings, we broadcast the change to any process that uses network communications.
  4. How each process applies the settings depends on the network module in use in that process. Where possible, proxy settings are applied on a per-request basis.

Because different modules treat environment variables differently, we avoid setting process environment variables and rely on things like proxy policies or options. The read-once caching behavior for NO_PROXY is a good example. In order to work around that behavior, we have to implement the NO_PROXY behavior ourselves. If the URL matches one of the patterns in NO_PROXY, we skip applying a proxy policy to that request.

If the SDK supported a “no proxy” list when creating a proxy policy, that would remove the need for us to do the no-proxy check ourselves.

Here’s our work item: microsoft/AzureStorageExplorer#2685

1reaction
craxalcommented, Jul 14, 2021

@xirzec We’re already doing that, actually. We create a new client for every operation that is performed. Then we discard it when the operation completes and returns.

Historically, we never relied on environment variables. But users were reporting issues when their environments had these variables set. Since the underlying networking modules already used these variables, we thought at first just using them would be the way to go, and it seemed to work with HTTPS_PROXY and HTTP_PROXY.

Since environment variables are essentially language/platform-independent versions of global variables…well, we learned that wasn’t a good idea.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with HTTP Proxies | OpenShift Container Platform 3.11
The NO_PROXY environment variable lists all of the OpenShift Container Platform components and all IP addresses that are managed by OpenShift Container ...
Read more >
Java Networking and Proxies
All proxies are defined by a host name and a port number. The later is optional as, if it is not specified, a...
Read more >
Can't consume web services via an HTTP proxy server
To designate the proxy server explicitly, use either the Machine. config or Web. config file, or specify the server programmatically.
Read more >
C# Connecting Through Proxy
config. You can programmatically create a proxy like so: HttpWebRequest request = (HttpWebRequest)WebRequest. Create("[ultimate destination of your request]"); ...
Read more >
Proxy server settings
Use this page to perform advanced configuration on a proxy server. Proxy settings enable the system administrator to fine tune the behavior of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found