diff --git a/core/lib/Foswiki.spec b/core/lib/Foswiki.spec index d596ae4891..4f532f7e96 100644 --- a/core/lib/Foswiki.spec +++ b/core/lib/Foswiki.spec @@ -1084,6 +1084,10 @@ $Foswiki::cfg{AccessibleHeaders} = ['Accept-Language', 'User-Agent']; # http://username:password@proxy.your.company:8080. $Foswiki::cfg{PROXY}{HOST} = undef; +# **STRING 50 LABEL="No Proxy" CHECK="undefok emptyok"** +# List of domains that are accessed directly instead of going by the proxy. +$Foswiki::cfg{PROXY}{NoProxy} = ''; + # **BOOLEAN LABEL="Client IP" ** # Foswiki normally uses the REMOTE_ADDRESS as the client IP. If Foswiki is behind # a proxy, Foswiki will see the proxy's address as the Client IP. Enable this switch if you diff --git a/core/lib/Foswiki/Net.pm b/core/lib/Foswiki/Net.pm index df157d7cf9..f9a6a7ce70 100644 --- a/core/lib/Foswiki/Net.pm +++ b/core/lib/Foswiki/Net.pm @@ -116,6 +116,11 @@ sub getExternalResource { my $uri = URI::URL->new($url); my $proxyHost = $this->{PROXYHOST} || $Foswiki::cfg{PROXY}{HOST}; my $puri = $proxyHost ? URI::URL->new($proxyHost) : undef; + my @noProxy = + ( $puri && $Foswiki::cfg{PROXY}{NoProxy} ) + ? split( /\s*,\s*/, $Foswiki::cfg{PROXY}{NoProxy} ) + : undef; + my $request; require HTTP::Request; @@ -138,6 +143,7 @@ sub getExternalResource { if ( $uri->can("userinfo") && defined $uri->userinfo() ); my $ua = new Foswiki::Net::UserCredAgent( $user, $pass ); $ua->proxy( [ 'http', 'https' ], $puri->as_string() ) if $puri; + $ua->no_proxy(@noProxy) if @noProxy; my $response = $ua->request($request); return $response; }