Support » Plugin: BuddyPress Docs » cdn issue with pdf attachments

  • Hello,
    I love your plugin and found out if a doc has a pdf document attached and download link switsches from http://www.mysite.com to http://cdn.mysite.com for example, the attached pdf cannot be downloaded. Link switches to login page after click and interpreted the cdn link without loggedin session link.

    Use WP 4.8, BP 2.8.2, BP Docs 1.9.4 and KeyCDN as cdn hoster

    Any help?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author David Cavins

    (@dcavins)

    Hi @per4mance-

    I’ve not used BP Docs with a CDN for media. I’ll ask around, but I don’t want you to get your hopes up that there’s a simple solution forthcoming. 🙂

    -David

    @dcavins
    thank you for your fast answer. Maybe is it possible to block attachments within the plugin to share with cdn networks?
    With other plugins like rtmedia for WordPress, BuddyPress and bbPress https://de.wordpress.org/plugins/buddypress-media/ it works perfectly with cdn. All documents and photo files can be downloaded over a cdn network without missing the rules. Maybe you found there some coding ideas?

    -Thorsten

    Plugin Author David Cavins

    (@dcavins)

    Hi @per4mance-

    The other media applications you mention are really apples and oranges to BP Docs because BP Docs has to restrict access to attachments. Most other WP media plugins just let WP handle the media, but we have to use custom file paths with custom .htaccess rules.

    So I’m not sure what the answer is.

    BEst,

    -David

    Hi @dcavins,

    thank you for your reply. Please check this plugin too:
    https://de.wordpress.org/plugins/buddydrive/ because imath developped this plugin also and there all uploaded files for filesharing do not use cdn.

    Best,
    -Thorsten

    Hi @dcavins,

    Found one more interesting issue within BuddyPress Groups, see attached screenshots:

    1. https://www.screencast.com/t/0q98Mwpu0
    2. https://www.screencast.com/t/dolSV6XW8tF

    Can you check this please?

    Best,
    -Thorsten

    Plugin Author Boone Gorges

    (@boonebgorges)

    @per4mance – Can you say more about your CDN setup? What WP plugin are you using to send uploads to the CDN? (The plugins I know of have a couple different kinds of techniques for handling this sort of thing.)

    Hi @boonebgorges!

    I’m using the original KeyCDN plugin https://de.wordpress.org/plugins/cdn-enabler/ because I’m using KeyCDN.

    Plugin Author Boone Gorges

    (@boonebgorges)

    @per4mance – It looks to me like the plugin doesn’t actually handle the loading of WP assets into the CDN. You must be managing that process separately – either manually, or via some additional script. Can you confirm?

    I’m also not seeing anything in the plugin itself that would result in URLs being rewritten on the front end. The way thet cdn-enabler plugin works is by detecting download requests, and then forwarding them to the CDN. But your screenshot shows that something is changing the way the URLs are output when the HTML is built. So there must be something else going on here. Perhaps you’re using some other plugins from this list? https://www.keycdn.com/support/keycdn-wordpress-plugins/

    The fact that you’re seeing different URLs in groups and in global directories does indicate that something is inconsistent in Docs itself, but it’s difficult to come up with a solution without knowing exactly how the CDN rewrites are working. So, any additional info you can provide would be helpful.

    @boonebgorges

    First of all thank you for your answer.
    Don’t know much about handling of WP assets, sorry. I know that e.g. https://de.wordpress.org/plugins/buddypress-media/ works without any issue handling jpeg, gif, png, pdf, doc etc files with KeyCDN. The plugin works with same righst WP created. So it doesn’t matter if the url https://www.mydomain.com/securepath/docu.pdf switches to https://cdn.mydomain.com/securepath/docu.pdf. If someone tries to access https://cdn.mydomain.com/securepath/docu.pdf he has to login to https://www.mydomain.com/ first. That means the plugin uses rewriting rules, so nobody knows the original file path where the doc has been located. KeyCDN works in the same way where an original website has been placed. That’s how I understand the sence of a cdn system spreads files.

    Second
    Tested another site where I’ve installed KeyCDN caching plugin and BP docs. Published a doc with public attachment (not group related) . The url generated with cdn and my click on it showed the pdf on screen (no download function). It seems that the KeyCDN caching plugin generates differently urls in comparison to W3 Total Cache.

    See: https://www.screencast.com/t/bjzlQ0Y8r

    Changed the rights for doc to logged in users, pdf is accessable also if someone knows the cdn file path. Switched the rights to the owner only but everything is accessable as before.

    The other site where the screenshots came from uses W3 Total Cache.

    See: https://www.screencast.com/t/8W6NLCc2H0br

    On both sites I use this plugin too https://de.wordpress.org/plugins/jch-optimize/ as a pro version. There I found in Pro Feature Tab the CDN/Cookieless Domain part with information:

    Enter your CDN or cookieless domain here. The plugin will load all static files including background images, combined javascript and css files, and generated sprite from this domain. This requires that this domain is already set up and points to your site root. You can also use multiple domains and the plugin will alternate the domains among the static files. You can also select the file types that you want to be loaded over these domains.

    There I deactivated for domain cdn.edunetz.org the static file ‘pdf’ and now your plugin generates attachments without ‘cdn’. But interestingly this doesn’t happen on the other site where KeyCDN caching plugin is installed instead of W3 Total Cache.

    Third
    You’re right, because only found an inconsistence with your plugin for now.

    I’ll hope that my founds are helpful for you!

    Kindest regards,
    Thorsten

    PS: Maybe your plugin handles Docs with BP Groups functionality different?

    Plugin Author Boone Gorges

    (@boonebgorges)

    > Maybe your plugin handles Docs with BP Groups functionality different?

    Possibly, but knowing this is not enough to come up with a fix. In order to determine what the “right” behavior is, I need to understand better what the intended behavior ought to be.

    When you upload a file through WordPress – whether through Docs, BuddyPress Media, BuddyDrive, Dashboard > Media – the files are usually uploaded to your site’s upload directory (either wp-content/uploads or wp-content/blogs.dir). CDN plugins work by mirroring these files on CDN servers, and then rewriting URLs to point to the mirrored files. It appears that Docs files are not properly being mirrored to the CDN, and further, it appears that in some cases Docs URLs are not being properly rewritten to point to the CDN (with the result that they point to the WP server, which results in working links). But what I’ve seen so far in the CDN plugin doesn’t explain *either* how the mirror works *or* how the URL rewriting works.

    It’s possible that jch-optimize is doing the rewriting, and that Docs attachment rewrites are failing in some cases because of a mismatched regular expression. Fixing this would break *all* Docs attachment links, since all links would then point to the CDN, where the files aren’t being properly mirrored.

    So the root issue is that the CDN is not receiving the files, while the inconsistent URLs in groups are a secondary issue. But without understanding how CDN file mirror works, I’m afraid it’s hard to debug.

    Perhaps you can give a more complete list of relevant plugins that you’re using? If you’ve recently set up a site from scratch, perhaps you can recall the plugins/configs you put in place to make the CDN work for other parts of the site?

    @boonebgorges
    Ok I can send you the configuration list of my site with all details. Do you have an Email or a more secure way to give you these details?

    Plugin Author Boone Gorges

    (@boonebgorges)

    Email me at my w.org username @ gmail. Thanks.

    sent 🙂

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