ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
reverseproxy.php
Go to the documentation of this file.
1<?php
2
3// The url we're proxying to.
4$remoteUrl = 'http://example.org/';
5
6// The url we're proxying from. Please note that this must be a relative url,
7// and basically acts as the base url.
8//
9// If your $remoteUrl doesn't end with a slash, this one probably shouldn't
10// either.
11$myBaseUrl = '/reverseproxy.php';
12// $myBaseUrl = '/~evert/sabre/http/examples/reverseproxy.php/';
13
16
17// Find the autoloader
19 __DIR__ . '/../vendor/autoload.php',
20 __DIR__ . '/../../../autoload.php',
21 __DIR__ . '/vendor/autoload.php',
22
23];
24
25foreach ($paths as $path) {
26 if (file_exists($path)) {
27 include $path;
28 break;
29 }
30}
31
32
33$request = Sapi::getRequest();
34$request->setBaseUrl($myBaseUrl);
35
37
38// Removing the Host header.
39$subRequest->removeHeader('Host');
40
41// Rewriting the url.
42$subRequest->setUrl($remoteUrl . $request->getPath());
43
45
46// Sends the HTTP request to the server
48
49// Sends the response back to the client that connected to the proxy.
50Sapi::sendResponse($response);
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
A rudimentary HTTP client.
Definition: Client.php:44
PHP SAPI.
Definition: Sapi.php:31
$subRequest
$paths
foreach($paths as $path) $request
$remoteUrl
Definition: reverseproxy.php:4
$client
$myBaseUrl
$response