We would like to pass our requests through a reverse proxy, so the contents could be cached locally.
Here is our current workaround. We hope the SDK could support this feature.
// SEE: Aws\Middleware::contentType() and Aws\S3\S3Client::__construct()
function withReverseProxy($s3Client, array $proxyConf)
{
$s3Client->getHandlerList()->appendBuild(function (callable $handler) use ($proxyConf) {
return function ($command, $request = null) use ($handler, $proxyConf) {
$origUri = $request->getUri();
$request2 = $request
->withUri($origUri->withHost($proxyConf["ProxyHost"])
->withPort($proxyConf["ProxyPort"]))
->withHeader("Host", $origUri->getHost());
return $handler($command, $request2);
};
}, "s3.with_reverse_proxy");
}
withReverseProxy($s3Client, ["ProxyHost" => "my-proxy.acme.com", "ProxyPort" => 8080]);
Could you instead use the ['http']['proxy'] configuration option available on the SDK clients?
If we issue the ['http']['proxy'] option with 'scheme' => 'https', the proxy will not be able to cache the response.
A S3Client with the (forward) proxy option will initiate a CONNECT request, and all the following traffic between it and the S3 server will be TLS encrypted, which can not be comprehended by the proxy server.
This issue did annoy us, too. Please add support so we don't have to use ad-hoc solution, too.
Thank you for your feature request. We regularly review suggestions like these to help prioritize what features we add to the SDK. But, currently, we do not plan to add direct support for a reverse proxy to the AWS SDK for PHP.
Most helpful comment
If we issue the ['http']['proxy'] option with 'scheme' => 'https', the proxy will not be able to cache the response.
A S3Client with the (forward) proxy option will initiate a CONNECT request, and all the following traffic between it and the S3 server will be TLS encrypted, which can not be comprehended by the proxy server.