• So, we’re having to load our wordpress (multi-site) two ways. If people are on the intranet they load it at its regular URL. If they’re coming through externally they’re using an Azure proxy.

    I added this to wp-config.php and it works for everything except ajax calls, which keep getting called over the site_url which is the database (internal url, not proxified) for proxy users.

    /** Sets up WordPress vars and included files. */
    if (isset($_SERVER['HTTP_X_MS_PROXY']) && ($_SERVER['HTTP_X_MS_PROXY'] == 'AzureAD-Application-Proxy')) {
    $host = 'ourwebsite-external.msappproxy.net'; }
    else {
    $host = $_SERVER['HTTP_HOST']; }
    
    //$host = $_SERVER['HTTP_HOST'];
    $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT']===443)) ? 'https://' : 'https://';
    define('WP_SITEURL', $protocol . $host);
    define('WP_HOME', $protocol . $host);
    require_once(ABSPATH . 'wp-settings.php');

    How can I get the site to set the ajaxurl so that it uses the proxy address for external users and the regular site address for our intranet users?

    • This topic was modified 1 year, 11 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    ajaxurl is typically constructed by concatenating “/admin-ajax.php” to the return from admin_url(), which apparently returns your internal URL. The return value is filtered with “ajax_url”. Maybe you can conditionally set the proper URL based on $_SERVER[‘HTTP_X_MS_PROXY’] existence and value?

    It’s possible your theme or plugins arrive at ajaxurl value through different means, so the filter solution may fail to cover all situations. It’s a good place to start at least.

Viewing 1 replies (of 1 total)
  • The topic ‘Azure proxy – admin-ajax.php loads at original site_url’ is closed to new replies.