Learn how to route native PHP HTTP traffic through a QuotaGuard Static IP. Includes full code examples.
N/A
QUOTAGUARDSTATIC_URL=... php https.rbBe sure to set QUOTAGUARDSTATIC_URL to your Connection URL from the QuotaGuard Dashboard.
docker build -t qg-static-php-https-example .
docker run -e QUOTAGUARDSTATIC_URL=... qg-static-php-https-example
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
if (!getenv('QUOTAGUARDSTATIC_URL')) {
throw new Exception('Missing environment variable');
}
$quotaguard = parse_url(getenv('QUOTAGUARDSTATIC_URL'));
$client = new Client([
'proxy' => [
'http' => "http://{$quotaguard['user']}:{$quotaguard['pass']}@{$quotaguard['host']}:{$quotaguard['port']}",
'https' => "http://{$quotaguard['user']}:{$quotaguard['pass']}@{$quotaguard['host']}:{$quotaguard['port']}",
],
]);
$response = $client->request('GET', 'https://ip.quotaguard.com');
echo $response->getBody();
?>
FROM php:7.4-apache
WORKDIR /app/
# Install dependencies
RUN apt-get update && apt-get install -y \
curl \
zip \
unzip
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Install GuzzleHttp
RUN composer require guzzlehttp/guzzle
# Copy PHP script
COPY https.php https.php
CMD [ "php", "https.php" ]