Article 50Z2E cURL problem in EC2 on RHEL 8

cURL problem in EC2 on RHEL 8

by
redd9
from LinuxQuestions.org on (#50Z2E)
Hi everyone, I'm having a weird problem again and I'm sure I'm doing something dumb.

Basically, I have a PHP script running on an RHEL 8 EC2 box that is supposed to grab a video from an S3 bucket and display it in a browser.

However, I get the error
Code:Error executing "GetObject" on "https://my-bucket.s3.us-east-2.amazonaws.com/Folder/Item.mp4"; AWS HTTP error: cURL error 7: (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)when I try to access it. If I just copy that URL into a browser, I can access it no problem. I can also curl to download the file on my EC2 box directly.

I then tried running a script to curl google.com and server it up in a browser. That also failed, with no error. However, it succeeded when I ran it on my desktop.

I have even tried completely opening up the firewall on my EC2 instance, hardcoding credentials, and making the object public in S3, but no luck. I still suspect this may be some kind of permissions issue - any ideas on what it could be?

My script here:
PHP Code:<?php
ini_set('display_errors',1);
require 'vendor/autoload.php';

use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;

$bucket = 'my-bucket';
$keyname = 'Folder/File.mp4';

$s3 = new S3Client([
'version' => 'latest',
'region' => 'us-east-2',
'credentials' => [
'key' => 'ABC123ABC123ABC123ABC123',
'secret' => 'ABC123ABC123ABC123ABC123ABC123ABC123',
],
]);

try {
$result = $s3->getObject([
'Bucket' => $bucket,
'Key' => $keyname
]);

header("Content-Type: {$result['ContentType']}");
echo $result['Body'];
} catch (S3Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
?>Update: Forgot to add my script is essentially copied and pasted from the Amazon website, I checked in phpinfo that I have cURL support, and print_r(curl_getinfo($ch)); produces this output: Array ( [url] => http://google.com/ [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0 [namelookup_time] => 0 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [redirect_url] => [primary_ip] => [certinfo] => Array ( ) [primary_port] => 0 [local_ip] => [local_port] => 0 )

Seems to be the same problem that this person has https://www.sitepoint.com/community/t/curl-not-working/3604/10 except there is no proxy (unless AWS adds one somehow?)latest?d=yIl2AUoC8zA latest?i=USkXbnnc1sg:LkBi0SQiZnM:F7zBnMy latest?i=USkXbnnc1sg:LkBi0SQiZnM:V_sGLiP latest?d=qj6IDK7rITs latest?i=USkXbnnc1sg:LkBi0SQiZnM:gIN9vFwUSkXbnnc1sg
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments