Learn how to securely route native PHP HTTP traffic through a QuotaGuard Shield proxy. Includes full code examples and Dockerfile.
This only requires curl, which generally is installed alongside PHP.
QUOTAGUARDSHIELD_URL=... php https.phpdocker build -t qg-shield-php-https-example .
docker run -e QUOTAGUARDSHIELD_URL=... qg-shield-php-https-example<?php
function lookup(){
$quotaguard_env = getenv("QUOTAGUARDSHIELD_URL");
$quotaguard = parse_url($quotaguard_env);
$proxyUrl = $quotaguard['host'].":".$quotaguard['port'];
$proxyAuth = $quotaguard['user'].":".$quotaguard['pass'];
$url = "https://ip.quotaguard.com/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxyUrl);
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyAuth);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);
$response = curl_exec($ch);
return $response;
}
$res = lookup();
print_r($res);
?>FROM php:latest
COPY https.php /app/https.php
WORKDIR /app/
ENTRYPOINT [ "php", "https.php" ]