Commit d1327dc0d28a2f747a43a793a09b3037a01ad445
1 parent
cf197d4f
Exists in
master
and in
9 other branches
Fix RemoteData access behind a proxy
Showing
4 changed files
with
59 additions
and
12 deletions
Show diff stats
CMakeLists.txt
... | ... | @@ -32,15 +32,17 @@ find_package( LibXML2 REQUIRED ) |
32 | 32 | get_filename_component(NETCDFLIB_DIR ${NETCDFLIBRARIES} PATH) |
33 | 33 | get_filename_component(DDCLIENTLIB_DIR ${DDCLIENTLIBRARIES} PATH) |
34 | 34 | |
35 | -configure_file ( | |
36 | - "${CMAKE_SOURCE_DIR}/scripts/DDServer.env.in" | |
37 | - "${CMAKE_SOURCE_DIR}/scripts/DDServer.env" | |
38 | -) | |
39 | - | |
40 | 35 | set(DDSERVICE_URL $ENV{DDSERVICE_URL}) |
41 | 36 | set(DDRESPATH $ENV{DDRESPATH}) |
42 | 37 | set(DDBASEDATA $ENV{DDBASEDATA}) |
43 | 38 | set(DDBASEINFO $ENV{DDBASEINFO}) |
39 | +set(PROXY_HOST $ENV{PROXY_HOST}) | |
40 | +set(PROXY_USERPWD $ENV{PROXY_USERPWD}) | |
41 | + | |
42 | +configure_file ( | |
43 | + "${CMAKE_SOURCE_DIR}/scripts/DDServer.env.in" | |
44 | + "${CMAKE_SOURCE_DIR}/scripts/DDServer.env" | |
45 | +) | |
44 | 46 | |
45 | 47 | configure_file ( |
46 | 48 | "${CMAKE_SOURCE_DIR}/src/DDSERVICES/SOAP/DDserverWeb_ini.php.in" |
... | ... |
compil.sh
1 | 1 | #!/bin/sh |
2 | 2 | |
3 | 3 | export INSTALL_DIR="/opt/local" |
4 | -export DDSERVICE_URL="http://apus.irap.omp.eu/NEWAMDA/DDService" | |
5 | -export DDRESPATH="/home/budnik/DDBASE" | |
6 | -export DDBASEDATA="/home/budnik/DDBASE/DATA" | |
7 | -export DDBASEINFO="/home/budnik/DDBASE/INFO" | |
4 | +export DDSERVICE_URL="http://amdadev.fr/DDService" | |
5 | +export DDRESPATH="/var/amda-data/" | |
6 | +export DDBASEDATA="/home/budnik/AMDA-NG.core/DDBASE/DATA" | |
7 | +export DDBASEINFO="/home/budnik/AMDA-NG.core/DDBASE/INFO" | |
8 | +#export PROXY_HOST="" | |
9 | +#export PROXY_USERPWD="" | |
8 | 10 | |
9 | 11 | echo "Install dir. : ${INSTALL_DIR}" |
10 | 12 | echo "DDService Url : ${DDSERVICE_URL}" |
11 | 13 | echo "DD.res path : ${DDRESPATH}" |
12 | 14 | echo "DDBASE DATA path : ${DDBASEDATA}" |
13 | 15 | echo "DDBASE INFO path : ${DDBASEINFO}" |
16 | +if [ -n "$PROXY_HOST" ] | |
17 | +then | |
18 | + echo "Proxy host : ${PROXY_HOST}" | |
19 | +fi | |
20 | +if [ -n "$PROXY_USERPWD" ] | |
21 | +then | |
22 | + echo "Proxy user/pwd : ${PROXY_USERPWD}" | |
23 | +fi | |
14 | 24 | read -p "Press any key to continue..." |
15 | 25 | |
16 | 26 | export NETCDF_ROOT=$INSTALL_DIR |
... | ... |
scripts/DDServer.env.in
... | ... | @@ -8,6 +8,9 @@ LD_LIBRARY_PATH=$DDLIB/:@NETCDFLIB_DIR@:@libcdf_LIBRARY_DIR@:@USRLIB_DIR@ |
8 | 8 | DATAMANAGER=@CMAKE_INSTALL_PREFIX@/bin/DATAMANAGER |
9 | 9 | REMOTEDATA=@CMAKE_INSTALL_PREFIX@/bin/REMOTEDATA |
10 | 10 | CALLEXT=@CMAKE_INSTALL_PREFIX@/bin/CALLEXT |
11 | +PROXY_HOST=@PROXY_HOST@ | |
12 | +PROXY_USERPWD=@PROXY_USERPWD@ | |
11 | 13 | |
12 | 14 | export DDBASE DDPATH DDBASEBIN DDLIB LD_LIBRARY_PATH |
13 | 15 | export DATAMANAGER REMOTEDATA CALLEXT |
16 | +export PROXY_HOST PROXY_USERPWD | |
... | ... |
src/REMOTEDATA/CDAWEB.php
... | ... | @@ -42,21 +42,50 @@ class CDAWEB extends RemoteDataCenterClass |
42 | 42 | { |
43 | 43 | error_log("CDAWEB Proxy creation on ".date("Y-m-d\TH:i:s").PHP_EOL,3,log); |
44 | 44 | error_log("CDAWEB Proxy creation on ".date("Y-m-d\TH:i:s").PHP_EOL,3,err); |
45 | + | |
46 | + $this->initStreamContext(); | |
45 | 47 | |
46 | 48 | $this->getAllSpaseDatasets(); |
47 | 49 | } |
48 | 50 | |
49 | - private function openConnection() | |
50 | - { | |
51 | + private function openConnection() | |
52 | + { | |
51 | 53 | $this->ch = curl_init(); |
52 | 54 | curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1); |
53 | - curl_setopt($this->ch, CURLOPT_TIMEOUT, 60); | |
55 | + curl_setopt($this->ch, CURLOPT_TIMEOUT, 60); | |
56 | + // Add proxy definition | |
57 | + $PROXY_HOST=getenv('PROXY_HOST'); | |
58 | + $PROXY_USERPWD=getenv('PROXY_USERPWD'); | |
59 | + if (!empty($PROXY_HOST)) { | |
60 | + curl_setopt($this->ch, CURLOPT_PROXY, getenv('PROXY_HOST')); | |
61 | + if (!empty($PROXY_USERPWD)) { | |
62 | + curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, getenv('PROXY_USERPWD')); | |
63 | + } | |
64 | + } | |
54 | 65 | } |
55 | 66 | |
56 | 67 | private function closeConnection() |
57 | 68 | { |
58 | 69 | curl_close($this->ch); |
59 | 70 | } |
71 | + | |
72 | + private function initStreamContext() | |
73 | + { | |
74 | + $PROXY_HOST=getenv('PROXY_HOST'); | |
75 | + $PROXY_USERPWD=getenv('PROXY_USERPWD'); | |
76 | + if (!empty($PROXY_HOST)) { | |
77 | + $context = array( | |
78 | + 'http' => array( | |
79 | + 'proxy' => "tcp://$PROXY_HOST", | |
80 | + 'request_fulluri' => true, | |
81 | + ), | |
82 | + ); | |
83 | + if (!empty($PROXY_USERPWD)) { | |
84 | + $context['http']['header'] = "Proxy-Authorization: Basic ".base64_encode($PROXY_USERPWD); | |
85 | + } | |
86 | + stream_context_set_default($context); | |
87 | + } | |
88 | + } | |
60 | 89 | |
61 | 90 | protected function setDataViewURL() |
62 | 91 | { |
... | ... | @@ -367,6 +396,7 @@ class CDAWEB extends RemoteDataCenterClass |
367 | 396 | |
368 | 397 | protected function existsMasterCdf($dsId) |
369 | 398 | { |
399 | + $this->initStreamContext(); | |
370 | 400 | $file = CDAWebConfigClass::$masterUrl.strtolower($dsId)."_00000000_v01.cdf"; |
371 | 401 | $file_headers = @get_headers($file); |
372 | 402 | |
... | ... | @@ -383,6 +413,7 @@ class CDAWEB extends RemoteDataCenterClass |
383 | 413 | |
384 | 414 | protected function getMasterCdf($dsId) |
385 | 415 | { |
416 | + $this->initStreamContext(); | |
386 | 417 | $file = CDAWebConfigClass::$masterUrl.strtolower($dsId)."_00000000_v01.cdf"; |
387 | 418 | $file_headers = @get_headers($file); |
388 | 419 | |
... | ... | @@ -394,6 +425,7 @@ class CDAWEB extends RemoteDataCenterClass |
394 | 425 | |
395 | 426 | public function getData($ds, $start, $stop) |
396 | 427 | { |
428 | + $this->initStreamContext(); | |
397 | 429 | $this->openConnection(); |
398 | 430 | $this->setDataViewURL(); |
399 | 431 | |
... | ... |