The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

cPanel, CURL and curl_exec to self issue

Discussion in 'General Discussion' started by InteractM, Aug 13, 2013.

  1. InteractM

    InteractM Well-Known Member

    Joined:
    Apr 2, 2013
    Messages:
    133
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hi,

    I have moved site from another server running PLEKS to the server with cPanel. Both servers have installed PHP 5.2.17 with CURL support but after site move to cPanel site is crashing on curl_exec to "self" (part of the web site with blog CMS).

    Code for that part looks like:

    PHP:
                                # INSTANTIATE CURL.
                                
    $curl curl_init();

                                
    # CURL SETTINGS.
                                
    curl_setopt($curlCURLOPT_URL"http://www.mydomain.com/news/index.php?tempskin=_rss2");
                                
    curl_setopt($curlCURLOPT_RETURNTRANSFER1);
                                
    curl_setopt($curlCURLOPT_CONNECTTIMEOUT0);

                                
    # GRAB THE XML FILE.
                                
    $xmlData curl_exec($curl);

                                
    curl_close($curl);

                                
    # SET UP XML OBJECT.
                                
    $xmlObjData simplexml_load_string$xmlData );

                                
    $tempCounter 0;

                                foreach ( 
    $xmlObjData->channel->item as $item )
                                {                    
                                    
    # DISPLAY ONLY 10 ITEMS.
                                    
    if ( $tempCounter 10 )
                                    {
                                        echo 
    "<li><a href=\"{$item -> link}\">{$item -> title}</a></li>
                                "
    ;
                                    }

                                    
    $tempCounter += 1;
                                }

                                 
    ?>    
    Any clue why cPanel server can't handle that?

    PS.
    EasyApache profile details returns that:

    Thanks
     
    #1 InteractM, Aug 13, 2013
    Last edited: Aug 13, 2013
  2. InteractM

    InteractM Well-Known Member

    Joined:
    Apr 2, 2013
    Messages:
    133
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Well, it looks like cPanel is blocking CURL connection to "self". curl_error returns

    Any clue?
     
  3. InteractM

    InteractM Well-Known Member

    Joined:
    Apr 2, 2013
    Messages:
    133
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
  4. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    Are you using ModSecurity?
     
  5. InteractM

    InteractM Well-Known Member

    Joined:
    Apr 2, 2013
    Messages:
    133
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Nope. Should I?
     
  6. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    I meant that ModSecurity might block those requests.
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  8. InteractM

    InteractM Well-Known Member

    Joined:
    Apr 2, 2013
    Messages:
    133
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    It is custom developed but simple pull for XML. As far wget is making connection failure it is not a script issue, because http://www.mydomain.com/news/index.php?tempskin=_rss2 is available through the browser.

    Also when I will do cURL connection to google.com (or something not on my cPanel installation) I'm able to execute cURL.
     
  9. InteractM

    InteractM Well-Known Member

    Joined:
    Apr 2, 2013
    Messages:
    133
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    After digging through server configuration as well firewall got it solved with creating a loopback NAT.
     
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    I am happy to hear you were able to resolve the issue. Thank you for sharing the solution with us.
     
Loading...

Share This Page