• I have WordPress installed on a Synology server, is not working any link to install, update, rss, etc. that goes to www.ads-software.com. Is blocked by the wp_safe_remote_request function. Specifically for not accomplishing the same_host restriction.

    I would like to keep this part in the code for safety, and I seen that there is a code for apply_filters , how can I make an exception for https://downloads.www.ads-software.com/ ?

    Tanks for help, everything I have tried has not worked.

    • This topic was modified 4 years, 3 months ago by intrapixel.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator Dion Hulse

    (@dd32)

    Meta Developer

    Hi @intrapixel,

    wp_safe_remote_request() should allow requests to www.ads-software.com downloads & API, and RSS feeds normally. The only limitations is that it blocks requests to certain “local” addresses and ports, to avoid issues around WordPress accessing things it shouldn’t (For example, being able to access the Synology management interface).

    What’s the exact error message you’re seeing from WordPress? The RSS feed display is the simplest place to see it, but you can also try the Site Health screens which may also show it.

    Moderator Dion Hulse

    (@dd32)

    Meta Developer

    @intrapixel Also, make sure you do NOT have WP_ACCESSIBLE_HOST or WP_HTTP_BLOCK_EXTERNAL defined in your wp-config.php file, or in a synology-helper plugin (although these should both be flagged in Site Health I believe)

    Thread Starter intrapixel

    (@intrapixel)

    Thanks for answering me. The errors are…
    In any update:
    “An error occurred while updating anything Download failed. A valid URL was not provided.”
    In theme install:
    “Downloading installation package from https://downloads.www.ads-software.com/theme/anyfile.zip…
    Download failed. A valid URL was not provided.”
    In admin Dashboard, WordPress news:
    “Error RSS: WP HTTP Error: A valid URL was not provided.”

    If I change “wp_safe_remote_request ()” to “$ args [‘reject_unsafe_urls’] = true false” that allow to get news on Dashboard. For updates and installs I need to change that on “wp_safe_remote_get ()”.

    My problem is whit “reject_unsafe_urls” is marking unsafe if it is not on localhost. I want to now how write the right code to add arguments to set www.ads-software.com as safe.

    • This reply was modified 4 years, 3 months ago by intrapixel.
    • This reply was modified 4 years, 3 months ago by intrapixel.
    Moderator Dion Hulse

    (@dd32)

    Meta Developer

    @intrapixel Sorry for the delayed follow up (If you mention me by @dd32 in your reply I’ll be able to get back to you faster)

    My problem is whit “reject_unsafe_urls” is marking unsafe if it is not on localhost. I want to now how write the right code to add arguments to set www.ads-software.com as safe

    By default, that IS a safe URL, so I think the problem here is that something (not WordPress itself) is triggering a failure case where it thinks that’s NOT safe.

    A valid URL was not provided

    That makes me think that wp_http_validate_url() is returning false, looking through that function, I suspect that the likely cause is a DNS resolution issue – if gethostbyname( 'www.ads-software.com' ) doesn’t return an IP it can fail.

    I think your best bet is to add some debugging and call wp_http_validate_url( 'https://www.ads-software.com/' ) and see where it’s failing and returning false – that function call should return the URL there if it’s working correctly.

    • This reply was modified 4 years, 3 months ago by Dion Hulse.
    Thread Starter intrapixel

    (@intrapixel)

    @dd32 Thanks. Yes, debug mode is active, and when I go to for example install new theme to see the “invalid url” error, nothing happen in the log file:

    called site
    single site, get site license or else default settings

    I must do something different in debug?

    Moderator Dion Hulse

    (@dd32)

    Meta Developer

    My apologies @intrapixel by debugging I meant adding something into the function so that where it looked like:

    
    if ( condition1 ) {
       var_dump( "Condition 1 caused it to fail" );
       return false;
    }
    

    I’ve copied the code from WordPress 5.6 into a gist to add some debugging: https://gist.github.com/dd32/a9e9e89101f7e4a18200376649aa3b55

    If you update the function with that and then run a few requests, you should see it output the reasoning for it being an invalid url.

    Thread Starter intrapixel

    (@intrapixel)

    @dd32 I add the code to http.php and now the error I got is this:

    Installation failed: string(146) "wp_http_validate_url 'https://downloads.www.ads-software.com/theme/twentytwenty.1.6.zip' is invalid, gethostbyname() failed to find correct DNS for site." {"success":false,"data":{"install":"theme","slug":"twentytwenty","debug":["Downloading installation package from https:\/\/downloads.www.ads-software.com\/theme\/twentytwenty.1.6.zip…","Download failed. A valid URL was not provided."],"errorMessage":"Download failed. A valid URL was not provided."}}

    • This reply was modified 4 years, 2 months ago by intrapixel.
    Moderator Dion Hulse

    (@dd32)

    Meta Developer

    I add the code to http.php and now the error I got is this… gethostbyname() failed to find correct DNS for site.

    Right, so your problem is that DNS resolution is broken, as I alluded to above.

    I’m not familiar enough with how synology works, but I think it’s docker based? you might need to force it to restart the instances/apps if they started before there was internet access or something.. or maybe even restarting the entire device..

    Unfortunately this isn’t really a WordPress problem, but rather a PHP/Synology problem, so you might be able to get more help through a Synology support forum. Mentioning that gethostbyname( 'www.ads-software.com' ) isn’t working.

    Thread Starter intrapixel

    (@intrapixel)

    @dd32 It’s not on docker, and I restart several times the server. Thank you very much for your help, now that I know what the error is, I will continue looking why gethostbyname does not work solving the DNS.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Allow external host on http.php’ is closed to new replies.