• Resolved aberkow

    (@aberkow)


    I’m doing an experiment with Azure Front Door as a CDN and I’m trying to understand if I’ve misconfigured something in W3TC on my subdomain-based multisite installation.

    This installation is on a dev server so the primary url is dev.mysite.com and sub-sites are at sub1.dev.mysite.com, sub2.dev.mysite.com, etc. Similarly, I’ve created urls and DNS entries for assets such as mainassets.mysite.com, subsite1assets.mysite.com, etc… and configured Front Door to accept these. sub1.dev.mysite.com uses a child theme of the theme running on dev.mysite.com (this is possibly important?).

    In W3TC’s network settings, I’ve disabled “Use single network configuration file for all sites” so that each site can have its own CDN settings as needed. In the main site’s settings, I’ve enabled the CDN on the general settings page and on the advanced page selected Generic Mirror and added the url to Front Door for it and this works perfectly.

    However, in the sub-site, when I did the same procedure (using it’s unique asset url instead), I get the following problem – assets such as images for the site have their urls re-written correctly and are served correctly from the CDN. The theme file urls are behaving very strangely though. They’re being re-written as https://subsite1assets.mysite.com/https://dev.mysite.com/content/themes/{rest-of-path} .

    I’m still working on debugging this, but I’m curious if you know of any reason it would occur. It’s possible that I may just need to use a single configuration for all sites, but I’m hoping not to do that if possible.

    Please let me know what additional information I can provide. Thanks for any insight you can offer!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @aberkow

    Thank you for reaching out and I am happy to help!
    Can you pease share the screenshot of the Performance>General Settings>CDN section for this subsite and let me know if you enabled the option to “Use specific settings” for this feature?

    Thanks!

    Thread Starter aberkow

    (@aberkow)

    Hi @vmarko,

    Thanks for getting back to me so quickly.

    I’m attaching a screenshot of the general settings CDN area and advanced settings where I’ve placed the mirror url just in case.

    Here are some additional debugging steps I’ve taken

    • deactivated all plugins besides w3tc (both at the network and individual site level)
    • activated the w3tc debug mode to check which file urls were being rewritten and how
    • checked to see if there would be a different result if I force all sites to use the same configuratin
    • attempted to use different themes on the subsite (just in case there was some specific theme functionality causing an issue)
    • confirmed the list of apache modules available (especially for mod_rewrite)
    • manually copy/pasted the htaccess config from the network install page to the main .htaccess file. NB – we use a slightly different configuration for .htaccess on the server where it’s located at /var/www/sites/site-dir/public_html/.htaccess rather than at .../wordpress/.htaccess it’s a long story and not something I can easily change right now, but that’s why I took that step.

    None of these steps have resolved the issue yet, but I’m still hopeful! Thanks so much for your help. Please let me know what other information or details I can provide.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @aberkow

    Thank you for your feedback.
    Can you please try to enable the option Fix document root path in Performance>General settings>Miscellaneous, save all settings and purge the cache and see if the rewrite path is corrected?

    Thanks!

    Thread Starter aberkow

    (@aberkow)

    Hi @vmarko

    I enabled the “fix document root path” option at the network level and confirmed that it holds at the subsite level. However, the result is the same. Subsites themes aren’t having their urls rewritten correctly. Since there was no change, I had to reactivate our authentication plugin.

    For reference, I get the following from wp cli

    wp @dev-mysite eval 'echo ABSPATH;'
    /var/www/sites/com.mysite.dev/public_html/wordpress/%

    On Friday I was trying to see if I could find any issues in w3tc’s Cdn_Plugin.php and Cdn_Core.php files as well. The server I’m running the site on has xdebug available so I’ll try using that to step through the code later today or tomorrow.

    Thanks,
    Adam

    Thread Starter aberkow

    (@aberkow)

    @vmarko

    Just a quick update – I’ve started testing this issue locally in docker (PHP 8.1) with a subdomain multisite setup similar to the one on our dev/prod servers. The issue is still here with the latest version (for those finding this later, that’s 2.7.5). Today I’m going to try downgrading the plugin to see if I can narrow things down a bit.

    Thanks,
    Adam

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @aberkow

    This is not specificaly related with the plugin, as you are using a Generic mirror, this only replaces the website URL with the URL of the CDN from where the images are served.
    The problem is not with the rewrite, as Generic mirror does what is supose to do, it’s related to the strucrure of your website environment.
    Is there any chance youc an share the acrual URL?

    Thanks!

    Thread Starter aberkow

    (@aberkow)

    Hi @vmarko,

    Sure thing, but can we do this over email or some other private channel? I’d prefer not to reveal too much in a forum.

    Separately (and just for clarification) images are being served from the CDN just fine. The issue seems strictly related to theme files.

    Thanks,
    Adam

    Thread Starter aberkow

    (@aberkow)

    Hi @vmarko,

    I set up a completely clean environment locally, started from scratch, and I agree that this is likely due to a misconfiguration on the server or in wp-config.php. I think looking at the way our projects got set up, someone (not me. I promise) set WP_HOME to a defined url. When I changed it to $_SERVER['HTTP_HOST]' locally, the urls were rewritten correctly. It’s late in the day for me now but I’m going to test this change on our dev server tomorrow morning. If it checks out, I’ll close this ticket.

    Thanks,
    Adam

    Thread Starter aberkow

    (@aberkow)

    Hi @vmarko,

    I’m closing the ticket. Thanks for your patience while I worked that out.

    For anyone who finds this later – WP_HOME and WP_SITEURL should be set to server variables rather than defined urls (e.g. 'https://' . $_SERVER['HTTP_HOST'] rather than ‘https://site.com`). Failing to do so interferes with how paths for generic mirrors are managed. On our server due to the use of configuration files to manage multiple environments, those definitions were being set incorrectly.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.