From 9ed340ba55aa7db6cf2385bfa89827fdda2c1c30 Mon Sep 17 00:00:00 2001 From: Ere Maijala <ere.maijala@helsinki.fi> Date: Wed, 2 Nov 2022 16:17:08 +0200 Subject: [PATCH] refs #22611 [finc] backport proxy excemptions * VF8 Make it possible to define the local address pattern for bypassing proxy. (#2604) --- config/vufind/config.ini | 10 +++++++++- local/config/vufind/config.ini | 12 ++++++++++-- .../VuFind/src/VuFind/Service/HttpServiceFactory.php | 4 +++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/config/vufind/config.ini b/config/vufind/config.ini index b804c92fb9b..05cc919264d 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -1313,8 +1313,16 @@ url = https://www.myendnoteweb.com/EndNoteWeb.html ;host = your.proxy.server ;port = 8000 -; Uncomment following line to set proxy type to SOCKS 5 +; Uncomment one of the following lines to set proxy type to SOCKS 5 or SOCKS 5 with +; name resolution done by proxy. Setting either of these will make VuFind use the +; curl adapter for HTTP requests. ;type = socks5 +;type = socks5_hostname +; This setting can be used to define a reqular expression pattern for addresses that +; should be considered local and bypass proxy when making requests. Default is: +;local_addresses = "@^(localhost|127(\.\d+){3}|\[::1\])@" +; Following example bypasses also any address starting with '192.168.': +;local_addresses = "@^(localhost|127(\.\d+){3}|\[::1\]|192\.168\.)@" ; Default HTTP settings can be loaded here. These values will be passed to ; the \Zend\Http\Client's setOptions method. diff --git a/local/config/vufind/config.ini b/local/config/vufind/config.ini index 94f2c250dbc..ba72c6c8e78 100644 --- a/local/config/vufind/config.ini +++ b/local/config/vufind/config.ini @@ -1327,8 +1327,16 @@ url = https://www.myendnoteweb.com/EndNoteWeb.html ;host = your.proxy.server ;port = 8000 -; Uncomment following line to set proxy type to SOCKS 5 -;type = socks5 +; Uncomment one of the following lines to set proxy type to SOCKS 5 or SOCKS 5 with +; name resolution done by proxy. Setting either of these will make VuFind use the +; curl adapter for HTTP requests. +; type = socks5 +; type = socks5_hostname +; This setting can be used to define a reqular expression pattern for addresses that +; should be considered local and bypass proxy when making requests. Default is: +; local_addresses = "@^(localhost|127(\.\d+){3}|\[::1\])@" +; Following example bypasses also any address starting with '192.168.': +; local_addresses = "@^(localhost|127(\.\d+){3}|\[::1\]|192\.168\.)@" ; Default HTTP settings can be loaded here. These values will be passed to ; the \Zend\Http\Client's setOptions method. diff --git a/module/VuFind/src/VuFind/Service/HttpServiceFactory.php b/module/VuFind/src/VuFind/Service/HttpServiceFactory.php index b4801c73280..c907119c349 100644 --- a/module/VuFind/src/VuFind/Service/HttpServiceFactory.php +++ b/module/VuFind/src/VuFind/Service/HttpServiceFactory.php @@ -75,6 +75,8 @@ class HttpServiceFactory implements FactoryInterface } $defaults = isset($config->Http) ? $config->Http->toArray() : []; - return new $requestedName($options, $defaults); + $config = !empty($config->Proxy->local_addresses) + ? ['localAddressesRegEx' => $config->Proxy->local_addresses] : []; + return new $requestedName($options, $defaults, $config); } } -- GitLab