0

I have an odd issue

We are in the midst of moving our site from on-premise servers (PHP 5.3) to Amazon EC2 cloud (PHP 7.0), both running apache

I have a php function that calls file_get_contents, which i then decode json for into a variable to do some processing

$klein->respond('POST', '/tracker/[i:id]', function ($request, $response, $service, $app) {
  $json = file_get_contents('test-url/eds.php?uid='.$request->param('id'));
  $result = json_decode($json);
...

On premises, this function works fine, In the Ec2 instance however, I am receiving a 504 gateway error.

here is the oddity, this works fine on the EC2 instance if I substitute the url for the on-premise site...no 504 error occurs

$json = file_get_contents('on-premise/eds.php?uid='.$request->param('id'));;

I tried replacing the file_get_contents with curl, and also had my ini_set to allow_url_fopen, neither remidied the situation, I'm beginning to think something larger is at play here

any help is greatly appreciated

Jay Rizzi
  • 4,196
  • 5
  • 42
  • 71
  • What happens if you try and use curl instead? – Scoots Jan 26 '18 at 17:09
  • @Scoots same 504 gateway timeout – Jay Rizzi Jan 26 '18 at 18:25
  • Hey there, Did you ever find a solution for this? I am running into the same issue --- PHP 5.3 to PHP 7, moving to ec2, etc. Thanks so much! – MrC Mar 26 '18 at 23:28
  • 1
    @MrC yes so the solution was when we moved to EC2, the security group was setup so that php could not make calls to itself, it was called a "hairpin" case ...we made changes to the security group attached load balancer to allow it – Jay Rizzi Apr 03 '18 at 14:05
  • Thank you for the note, @JayRizzi -- appreciate it! – MrC Apr 03 '18 at 14:56
  • @Mrc , I cant find anything that references 'hairpin' .. we are seeing a bit of slowness with file_get_contents and I wanted to see the fix you did. Is their a link to this? – Steve Jul 23 '18 at 22:44
  • 1
    @Steve sorry for the strange term, was just quoting a coworker, was word he used, verbatum the answer was we changed the load balancer security group to reference the backend security group to fix – Jay Rizzi Aug 17 '18 at 16:28

0 Answers0