Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1821543
reverseproxy.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
1 KB
Subscribers
None
reverseproxy.php
View Options
<?php
// The url we're proxying to.
$remoteUrl
=
'http://example.org/'
;
// The url we're proxying from. Please note that this must be a relative url,
// and basically acts as the base url.
//
// If your $remoteUrl doesn't end with a slash, this one probably shouldn't
// either.
$myBaseUrl
=
'/reverseproxy.php'
;
// $myBaseUrl = '/~evert/sabre/http/examples/reverseproxy.php/';
use
Sabre\HTTP\Sapi
;
use
Sabre\HTTP\Client
;
// Find the autoloader
$paths
=
[
__DIR__
.
'/../vendor/autoload.php'
,
__DIR__
.
'/../../../autoload.php'
,
__DIR__
.
'/vendor/autoload.php'
,
];
foreach
(
$paths
as
$path
)
{
if
(
file_exists
(
$path
))
{
include
$path
;
break
;
}
}
$request
=
Sapi
::
getRequest
();
$request
->
setBaseUrl
(
$myBaseUrl
);
$subRequest
=
clone
$request
;
// Removing the Host header.
$subRequest
->
removeHeader
(
'Host'
);
// Rewriting the url.
$subRequest
->
setUrl
(
$remoteUrl
.
$request
->
getPath
());
$client
=
new
Client
();
// Sends the HTTP request to the server
$response
=
$client
->
send
(
$subRequest
);
// Sends the response back to the client that connected to the proxy.
Sapi
::
sendResponse
(
$response
);
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Dec 24, 2:46 AM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
915263
Default Alt Text
reverseproxy.php (1 KB)
Attached To
rDAVCAL DokuWiki DAVCal PlugIn
Event Timeline
Log In to Comment