Skip to content

Instantly share code, notes, and snippets.

@erm3nda
Forked from ebuildy/init.sh
Last active July 22, 2020 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erm3nda/483f92fbe37ea08819a983082f694be3 to your computer and use it in GitHub Desktop.
Save erm3nda/483f92fbe37ea08819a983082f694be3 to your computer and use it in GitHub Desktop.
Setting PHP stream context from system env
echo "auto_prepend_file=/opt/www/proxy.php" >> /etc/php/php.ini
<?php
$proxy = getenv('http_proxy');
if (!empty($proxy)) {
$proxy = str_replace('http://', 'tcp://', $proxy);
echo "Found a proxy " . $proxy . PHP_EOL;
$context = array(
'http' => array(
'proxy' => $proxy,
'request_fulluri' => true,
'verify_peer' => false,
'verify_peer_name' => false,
),
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false
)
);
stream_context_set_default($context);
} else {
echo "Proxy not found" . PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment