php 在CWP上发出请求时出现代理问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 在CWP上发出请求时出现代理问题相关的知识,希望对你有一定的参考价值。

<?php

// Get the proxy info. getEnv returns false if environment var is not found
$ss_outbound_proxy = Environment::getEnv('SS_OUTBOUND_PROXY');
$ss_outbound_proxy_port = Environment::getEnv('SS_OUTBOUND_PROXY_PORT');

// Set the curl proxy variable
if ($ss_outbound_proxy && $ss_outbound_proxy_port) {
    $proxy = 'https://' . $ss_outbound_proxy.':'.$ss_outbound_proxy_port;
    curl_setopt($ch, CURLOPT_PROXY, $proxy);
}

// Set the curl proxy variable in the _config.php
if ($ss_outbound_proxy && $ss_outbound_proxy_port) {
    putenv('http_proxy=' . $ss_outbound_proxy.':'.$ss_outbound_proxy_port);
    putenv('https_proxy=' . $ss_outbound_proxy.':'.$ss_outbound_proxy_port);
}

以上是关于php 在CWP上发出请求时出现代理问题的主要内容,如果未能解决你的问题,请参考以下文章