Equivalent of iframe on server side

6.1k views Asked by At

Is there any way to create an "iframe-like" on server side ? The fact is, I need to acceed to certains page of my society's intranet from our website's administration part.

I already have a SQL link to the database that works fine, but here I would access to the pages without duplicating the source code on the webserver.

My infrasructure is the following:

The Webserver is in a DMZ and has the following local IP: 192.168.63.10. Our Intranet server is NOT in the DMZ and has the following IP: 192.168.1.20.

Our Firewall has serverals rules and I've just added the following: DMZ->LAN Allow HTTP/HTTPS traffic and LAN->DMZ Allow HTTP/HTTPS (just as we've done for the SQL redirection)

I've tried the following PHP function:

$ch = curl_init();

// set URL and other appropriate options (also tried with IP adress instead of domain)
curl_setopt($ch, CURLOPT_URL, "http://intranet.socname.ch/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);

I've also tried:

$page = file_get_contents('http://192.168.1.20/');
echo $page;

Or:

header('Location:http://192.168.1.20');

But in all thoses cases, it works fine from local but not from internet. From internet, it doesn't load and after a while, says that the server isn't responding.

Thanks for your help !

1

There are 1 answers

2
Jason Leung On BEST ANSWER

Your first and second solution could work. Can your webserver access 192.168.1.20? (try ping 192.168.1.20 on your webserver) or resolve the Hostname intranet.socname.ch ? (try nslookup intranet.socname.ch)

What you're looking for is called "proxy", here is a simple PHP project that I found: https://github.com/Alexxz/Simple-php-proxy-script

Download the repo, copy example.simple-php-proxy_config.php to simple-php-proxy_config.php and change $dest_host = "intranet.socname.ch";

It should do the trick! (may also need to change $proxy_base_url)