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

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

gongaiorg

問(wèn)題描述

問(wèn)題已解決:
是因?yàn)樵浦鳈C(jī)的問(wèn)題,需要在本地進(jìn)行解析,而且不能用公網(wǎng)ip,要用127.0.0.1
非常感謝大佬的指導(dǎo),解決了這個(gè)困擾大半天的困惑,大佬一語(yǔ)道破,解決問(wèn)題,非常感謝?。?!

1、部署在linux服務(wù)器上了,并且是兩個(gè)不同站點(diǎn)的網(wǎng)址請(qǐng)求,并非同一個(gè)進(jìn)程

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

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

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

curl訪問(wèn) 網(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);
    } 

3083 4 0
4個(gè)回答

不敗少龍

$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請(qǐng)求,請(qǐng)求其它網(wǎng)站都可以正常返回,但是請(qǐ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 用你代碼寫了這個(gè)是正??梢栽L問(wèn)的
    但是https://sso.21c.xin/passport/index/curl1?url=https://push.21c.xin/ 還是返回false

    應(yīng)該是服務(wù)器設(shè)置的問(wèn)題嗎

  • 不敗少龍 2023-04-23

    是不是對(duì)方的網(wǎng)站請(qǐng)求頭需要設(shè)置什么的

  • gongaiorg 2023-04-23

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

  • 不敗少龍 2023-04-23

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

  • 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

截圖,這能訪問(wèn)就怪了

  • gongaiorg 2023-04-23

    是哪里的問(wèn)題呢,不能訪問(wèn)

  • gongaiorg 2023-04-23

    https://push.21c.xin/ 是可以正常訪問(wèn)的啊
    curl方式為什么請(qǐng)求總是返回false呢

  • gongaiorg 2023-04-23

    同樣的代碼請(qǐng)求其它網(wǎng)址可以正常獲取

  • tanhongbin 2023-04-23

    你要請(qǐng)求的到底是哪個(gè)地址?然后你得代碼怎么寫的,請(qǐng)求的代碼粘貼一下瞅瞅就知道了

  • gongaiorg 2023-04-23

    public function curl1( )
    {
    $url = input('url')?:'https://push.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);
    }

    請(qǐng)求 https://push.21c.xin/
    url可以傳參,更改請(qǐng)求的網(wǎng)址

  • tanhongbin 2023-04-23

    你這段代碼你確定 你的$url 是 https://push.21c.xin/ 嘛 ,input獲取的是空的吧

  • tanhongbin 2023-04-23

    你需要打印一下$url 窗口看一下,是否是前端傳過(guò)來(lái)的值,我懷疑你得input()得不到 這個(gè)值

  • gongaiorg 2023-04-23

    input可以獲取到的,你可以更換url試一下

  • tanhongbin 2023-04-23

    你確定嘛?你還是打印一下看看,確定一下

  • gongaiorg 2023-04-23

    確定,測(cè)試過(guò)了,可以獲取的,并且更換其它url也是可以獲取到的

  • gongaiorg 2023-04-23

    就是不明白,是服務(wù)器哪里的設(shè)置問(wèn)題,curl請(qǐng)求獲取不到,總是返回false

  • gongaiorg 2023-04-23

    string(21) "https://push.21c.xin/"
    string(11) "curl 參數(shù)"
    string(21) "https://push.21c.xin/"
    string(0) ""
    string(3) "Get"
    array(0) {
    }
    string(17) "curl 參數(shù)結(jié)束"
    string(15) "$tmpInfo 信息"
    bool(false)
    int(52)
    int(0)

  • tanhongbin 2023-04-23

    我試試你得地址哈,我試試能不能訪問(wèn)

智佳思遠(yuǎn)

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

  • gongaiorg 2023-04-23

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

  • 智佳思遠(yuǎn) 2023-04-23

    php start.php status 截圖下

  • gongaiorg 2023-04-23

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

  • 智佳思遠(yuǎn) 2023-04-23

    我這瀏覽器都沒(méi)辦法訪問(wèn)你的域名,顯示超時(shí),telnet也連接超時(shí)。

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

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

  • gongaiorg 2023-04-23

    不應(yīng)該吧,push.21c.xin 和 sso.21c.xin 就解析在這個(gè)43.154.4.5服務(wù)器上

  • 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.

  • 智佳思遠(yuǎn) 2023-04-23

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

  • 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

截圖
截圖
沒(méi)有問(wèn)題呀我這里

  • gongaiorg 2023-04-23

    我用的curl訪問(wèn)的,你看看上面的請(qǐng)求方式哪里不對(duì)嗎

  • tanhongbin 2023-04-23

    我用的是這個(gè)GuzzleHttp\Client ,現(xiàn)在誰(shuí)還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

    我用你說(shuō)的這個(gè)類庫(kù),報(bào)錯(cuò)52,和curl是一樣的

  • tanhongbin 2023-04-23

    你這是電腦問(wèn)題嘛???

  • tanhongbin 2023-04-23

    我們都能請(qǐng)求,不知道為啥你請(qǐng)求不了

  • gongaiorg 2023-04-23

    應(yīng)該是服務(wù)器配置的問(wèn)題吧

  • tanhongbin 2023-04-23

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

  • tanhongbin 2023-04-23

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

  • gongaiorg 2023-04-23

    curl請(qǐng)求不存在跨域問(wèn)題吧,協(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 都試過(guò)了,都是返回false

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

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

  • gongaiorg 2023-04-23

    添加host解析 設(shè)置到本地127.0.0.1就可以了

年代過(guò)于久遠(yuǎn),無(wú)法發(fā)表回答
??