国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

已解決:網(wǎng)站部署后可以正常訪問,但是用curl請求時總是返回false。解決辦法:在服務器進行域名內(nèi)網(wǎng)ip解析。

gongaiorg

問題描述

問題已解決:
是因為云主機的問題,需要在本地進行解析,而且不能用公網(wǎng)ip,要用127.0.0.1
非常感謝大佬的指導,解決了這個困擾大半天的困惑,大佬一語道破,解決問題,非常感謝?。?!

1、部署在linux服務器上了,并且是兩個不同站點的網(wǎng)址請求,并非同一個進程

2、用webman框架,網(wǎng)站部署后可以正常訪問 https://push.21c.xin/ ,但是用curl請求網(wǎng)站時總是返回false,

3、同樣的代碼,更換請求其它網(wǎng)址可以正常返回值,這是服務器的配置問題嗎?怎么修改呢,找了很多方案都不行,特請教大佬!

測試網(wǎng)址:https://sso.21c.xin/passport/index/curl?url=https://baidu.com 可以正常返回百度的首頁內(nèi)容
var_dump($tmpInfo); 返回html源碼
var_dump(curl_errno($curl)); 返回0
var_dump(curl_getinfo($curl, CURLINFO_HTTP_CODE)); 返回200

curl訪問 網(wǎng)址 https://sso.21c.xin/passport/index/curl?url=https://push.21c.xin/ 卻返回為false
var_dump($tmpInfo); 返回false
var_dump(curl_errno($curl)); 返回52
var_dump(curl_getinfo($curl, CURLINFO_HTTP_CODE)); 返回0

    public function curl(  ): Response
    { 
        $curl = new Curl(); 
        $url =request()->get('url','https://sso.21c.xin');
        $result = $curl->get($url); 
        var_dump($result);
        return json($result);
    } 

3196 4 0
4個回答

不敗少龍

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'X-AjaxPro-Method:ShowList',
        'Content-Type: application/json; charset=utf-8',
        'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$data = curl_exec($ch);
curl_close($ch);
return json_decode($data, true);
  • gongaiorg 2023-04-23

    我寫的get請求,請求其它網(wǎng)站都可以正常返回,但是請求webman部署的網(wǎng)站不行,都是返回false

  • 不敗少龍 2023-04-23
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
  • gongaiorg 2023-04-23

    https://sso.21c.xin/passport/index/curl1?url=https://baidu.com 用你代碼寫了這個是正??梢栽L問的
    但是https://sso.21c.xin/passport/index/curl1?url=https://push.21c.xin/ 還是返回false

    應該是服務器設置的問題嗎

  • 不敗少龍 2023-04-23

    是不是對方的網(wǎng)站請求頭需要設置什么的

  • gongaiorg 2023-04-23

    請求的是我自己的服務器,現(xiàn)在做微服務架構,把模塊分離了,不知道服務器要怎么設置才能解決這個問題呢

  • 不敗少龍 2023-04-23

    http_get('https://push.21c.xin/') 我這直接請求你的這個 可以獲取到值啊

  • gongaiorg 2023-04-23

    你怎么寫的代碼啊
    public function curl1( )
    {
    $url = input('url')?:'https://sso.21c.xin';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $result = curl_exec($ch);
    curl_close($ch);
    var_dump($result);
    return json($result);
    }
    剛按照你發(fā)的代碼也是不可以呢,返回依然是false

  • 不敗少龍 2023-04-23

    $url =request()->get('url','https://sso.21c.xin'); 這楊寫呢

tanhongbin

截圖,這能訪問就怪了

智佳思遠

提問把系統(tǒng)環(huán)境帶上啊。如果是windows開發(fā),windows是單進程的,就一個進程不能自己請求自己

  • gongaiorg 2023-04-23

    我部署在linux服務器上了,并且是兩個不同的網(wǎng)址請求,并非同一個進程

  • 智佳思遠 2023-04-23

    php start.php status 截圖下

  • gongaiorg 2023-04-23

    已經(jīng)發(fā)到問題下面了

  • 智佳思遠 2023-04-23

    我這瀏覽器都沒辦法訪問你的域名,顯示超時,telnet也連接超時。

    telnet push.21c.xin 443
    Trying 43.154.4.5...
    ^C
    
    telnet sso.21c.xin 443
    Trying 43.154.4.5...
    ^C

    你的服務器估計也無法訪問你的域名,在你服務器上telnet sso.21c.xin 443 試下吧??纯词遣皇鞘褂昧舜?cdn什么的

  • gongaiorg 2023-04-23

    不應該吧,push.21c.xin 和 sso.21c.xin 就解析在這個43.154.4.5服務器上

  • gongaiorg 2023-04-23

    [root@mail sso.21c.xin]# telnet sso.21c.xin
    -bash: telnet: command not found
    [root@mail sso.21c.xin]# ping sso.21c.xin
    PING hk1.domainagent.pub (43.154.4.5) 56(84) bytes of data.

  • 智佳思遠 2023-04-23

    ping和telnet是不同的協(xié)議,一個icmp,一個tcp,ping通不代表tcp能連接,反過來也是。
    apt-get install telnet 或者 yum install telnet 裝下telnet命令
    telnet命令是 telnet sso.21c.xin 443,端口號加上

  • gongaiorg 2023-04-23

    [root@mail sso.21c.xin]# telnet sso.21c.xin 443
    Trying 43.154.4.5...
    Connected to sso.21c.xin.
    Escape character is '^]'.

tanhongbin

截圖
截圖
沒有問題呀我這里

  • gongaiorg 2023-04-23

    我用的curl訪問的,你看看上面的請求方式哪里不對嗎

  • tanhongbin 2023-04-23

    我用的是這個GuzzleHttp\Client ,現(xiàn)在誰還curl 什么年代了???

  • gongaiorg 2023-04-23

    GuzzleHttp\Exception\ConnectException: cURL error 52: Empty reply from server (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://push.21c.xin/

  • gongaiorg 2023-04-23

    我用你說的這個類庫,報錯52,和curl是一樣的

  • tanhongbin 2023-04-23

    你這是電腦問題嘛???

  • tanhongbin 2023-04-23

    我們都能請求,不知道為啥你請求不了

  • gongaiorg 2023-04-23

    應該是服務器配置的問題吧

  • tanhongbin 2023-04-23

    你是不是跨域了???你接口端webman的路由怎么寫的??

  • tanhongbin 2023-04-23

    還有你webman那邊是不是 nginx代理的,你得看看你得協(xié)議 是不是http1.0 的,你用的是http1.1請求的,導致協(xié)議不一致

  • gongaiorg 2023-04-23

    curl請求不存在跨域問題吧,協(xié)議是1.0

  • gongaiorg 2023-04-23

    location / {
    proxy_pass http://127.0.0.1:9901;
    index index.php index.html error/index.html;
    autoindex off;
    proxy_set_header Host $host;
    proxy_http_version 1.0;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

  • gongaiorg 2023-04-23

    1.1 和1.0 都試過了,都是返回false

  • PHP甩JAVA一條街 2023-04-23

    環(huán)境有問題吧?

  • gongaiorg 2023-04-23

    添加host解析 設置到本地127.0.0.1就可以了

年代過于久遠,無法發(fā)表回答
??