1

I have a PHP page located in https://example.com calling a web service to generate a PDF report located in https://example2.com. When the page is executed it says ERR_INVALID_RESPONSE. Both servers are Droplets hosted in Digital Ocean service.

Elsewhere I have another server with Cpanel and I have the same PHP page located in https://example3.com calling a web service to generate a PDF report located in https://example2.com. And I do not have this problem.

To my understanding, the problem is in the Apache config when calling the other domain. What configuration is necessary to review in Apache to solve this problem?

This is the fragment code for calling the web service

<?php
error_reporting(0);
session_start();
header('Content-Type: application/pdf');

// ...code to get $data

$server_output = return CallApi_PDF("POST", "https://example2.com/webservice", $data, $filename);
echo  $server_output;
?>

function CallApi_PDF($method, $url, $data, $filename=null){

    $additional_headers = array(
        'Content-Type: application/json',
    );

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $additional_headers);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    $server_output = curl_exec($ch);

    return $server_output;

}

Like I said before, this works on a server with Cpanel

1
  • All of your Apache configuration for example.com, potentially. You'll need to show us at least the part that relates to the web service, if you want us to help. Mar 27, 2018 at 22:51

0

You must log in to answer this question.

Browse other questions tagged .