guoyu4126
V2EX  ›  PHP

PHP 修改 HOSTS 本地 CURL 到本地

  •  
  •   guoyu4126 · Oct 10, 2018 · 4612 views
    This topic created in 2787 days ago, the information mentioned may be changed or developed.

    hosts 修改为 127.0.0.1 www.a.com 127.0.0.1 www.b.com

    Nginx 绑定对应域名。网站都可单独访问 但通过 a.com curl post/get 到 b.com 就访问超时

    Curl 中加上了

    curl_setopt($ch,CURLOPT_RESOLVE,[
    	"lvyou.myyoger.com:127.0.0.1"
    ]);
    

    也是不可以。。

    GuzzleHttp 也访问超时。

    $client = new Client();
    $request = $client->request('GET', $baseUrl, [
    'query' => $params
    ]);
    

    报错信息:PHP Fatal error: Maximum execution time of 30 seconds exceeded

    Curl 到外网就没问题

    3 replies    2018-10-16 12:16:10 +08:00
    Astralis
        1
    Astralis  
       Oct 10, 2018
    改成这样试试,curl 的 resolve 好像需要指定端口
    curl_setopt($ch,CURLOPT_RESOLVE,[
    "lvyou.myyoger.com:80:127.0.0.1"
    ]);
    mokeyjay
        2
    mokeyjay  
       Oct 10, 2018   ❤️ 1
    guoyu4126
        3
    guoyu4126  
    OP
       Oct 16, 2018
    @mokeyjay 解决掉了 谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2584 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 466ea39e · 33ms · UTC 15:52 · PVG 23:52 · LAX 08:52 · JFK 11:52
    ♥ Do have faith in what you're doing.