Hello everyone
I run this cURL PHP script on 3 different servers to get json data from another server. Here is the code:
<?php
$consid = "my_consid";
$secretKey = "my_secretkey";
date_default_timezone_set('UTC');
$tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));
$signature = hash_hmac('sha256', $consid."&".$tStamp, $secretKey, true);
$encodedSignature = base64_encode($signature);
$ch = curl_init();
$headers = array(
'X-cons-id: '.$consid.'',
'X-timestamp: '.$tStamp.'',
'X-signature: '.$encodedSignature.'',
'Content-Type: Application/JSON',
'Accept: Application/JSON'
);
curl_setopt($ch, CURLOPT_URL, "https://domain.tld/aplicaresws/rest/bed/read/xxxxxx/1/20");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'DEFAULT@SECLEVEL=1');
$content = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
$data = json_decode($content,true);
foreach ($data["response"] as $record) {}
$data2 = array( 'data' => $record );
$data3 = json_encode($data2);
$fp = fopen("bed_data.json", "w");
fwrite($fp, $data3);
fclose($fp);
?>
Server #1
Specs:
- localhost on Windows XAMPP
- Apache/2.4.53 (Win64) OpenSSL/1.1.1n PHP/7.4.29
- connection from Windows 10 laptop
Script ran succesfully and got result on json data.
Server #2
Specs:
- Linux Ubuntu 20.04 (aarch64) server on Raspberry Pi 3
- HestiaCP 1.6.7 with nginx php-fpm
- Apache/2.4.54 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/1.1.1f
- connection with broadband and dynamic dns from server to internet outside
Script ran succesfully and got result on json data.
Server #3
Specs:
- Linux Debian 11.4 (amd64) server on Contabo VPS
- HestiaCP 1.6.7 with nginx php-fpm
- Apache/2.4.54 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n
- connection with contabo broadband with static ip to internet outside
Script not succesful and got Gateway Time Out 504 error code.
Any advices or suggestions with the result on Server #3 that is failed.
Please need help to investigate this, thanks in advance.