[DigitalPoint] App for Cloudflare®

[DigitalPoint] App for Cloudflare® 1.8.2

No permission to download
If someone really wanted to do it, they could extend a few of the methods in the DigitalPoint\Cloudflare\League\Flysystem\Adapter\R2.php file... specifically the write operations to also write somewhere else. But I still think the sync option of rclone is going to have more advantages.
When Chinese new year is over I'll look at giving this a go, as I prefer not relying on another app.

I'm running on nvme so I think the delay will be negligible, but of course I'll run some benchmarks on this 😊
 
When Chinese new year is over I'll look at giving this a go, as I prefer not relying on another app.

I'm running on nvme so I think the delay will be negligible, but of course I'll run some benchmarks on this 😊
Isn't the whole idea to have a backup that you can restore from in case something was accidentally deleted by a user (or process)? Doing the backup at the abstracted filesystem level isn't going to help there since you are writing/deleting/updating to both filesystems in realtime. Just like you can't really use a database being replicated in realtime as a backup (as far as being able to recover records/tables... it would be limited to catastrophic disaster recovery if the entire database server failed). Doing things concurrently on two different filesystems is really only going to protect against R2 itself completely failing somehow, it's not going to help restore something that was accidentally deleted.

Obviously every setup is different, but this is my backup setup:

A full snapshot backup is done daily (all site files, all databases), then that backup is replicated to 8 (!!!! hah) different physical servers in the data center. Once a month, an off-site backup (in case something like a nuke hits the data center and all equipment ceased to exist) is done like so:
  • Files are kept for a year (so for example I could go back to a certain PHP or JavaScript file from last August)
  • Database backups are kept for 2 months (in my case, they are massive... multiple terabytes)
To date, I've never had to restore anything from a backup, local or offsite (knock on wood). I've built my setup to be fairly resilient so it's never been much of a worry (every physical server has 6 drives, of which any 2 can fail without causing issue... RAID-6). All physical servers have at least 1 "sibling"... meaning any server can go down planned or unplanned without any degradation for end-users (can do things like database software upgrades with zero downtime). Can do complete server operating system upgrades/installation without downtime. Can even do hardware changes to servers in a rolling fashion (which I've also done... shut down servers in a rolling fashion to pull all the RAM out of it and add higher density memory modules).

Anyway... got sidetracked. But my original question still stands... is replicating at the abstracted filesystem level really what you want to be doing (accidentally deleting an attachment on one deletes it on both).
 
Anyway... got sidetracked. But my original question still stands... is replicating at the abstracted filesystem level really what you want to be doing (accidentally deleting an attachment on one deletes it on both).
In my case yes 😊

[COLOR=hsl(var(--xf-editorFocusColor))]Because like yourself I take a full snap shot everyday, which will catch everything on the local disks 👍[/COLOR]
 
Two absolute noob questions that I've been unable to source an answer -

1) I've set everything up correctly I believe. Prior to moving images over using the CLI method described in FAQ - Images did not show, and were broken. Now I have used the CLI method to move, all seems fine (so far) and images are served. Is there a way to verify (apart from just seeing the images appear) that I can tell data and attachments are now served via cloudflare? I opened an image source, and the url appears the same as before (I think)

2) Do I need to actually create a subdomain, such as data.site.net in my host/cloudflare (cloudflare manages my dns) for this to work? I wasn't super clear during the set up process.

Thank you!
 
Hello

I initially had the same issue but my site works without issues.

No you do not need to create the subdomains - the app creates these for you providing you have set the correct API permissions.

It is important you have the paths correctly set so if you share some screenshots ill be able to advise where you went wrong.

I am sure @digitalpoint will reply but ill be happy to assist based on my previous similar issue.
 
Hello

I initially had the same issue but my site works without issues.

No you do not need to create the subdomains - the app creates these for you providing you have set the correct API permissions.

It is important you have the paths correctly set so if you share some screenshots ill be able to advise where you went wrong.

I am sure @digitalpoint will reply but ill be happy to assist based on my previous similar issue.
What screenshots do you need? Just from the r2 section in the admincp?

Thank you BTW!
 
I would need to path of the files in Cloudflare R2.
Normally the paths are wrong as I did the same thing. If you view my replies and @digitalpoint reply to me you will see it is usually the cli.

Are you using rclone to upload ?
 
So, this is the screenshot from the r2 interface in acp -

1708616540288.webp

I set up a data bucket, and attachment bucket. I added the buckets then to the r2 interface within acp, and selected the correct buckets for each one. I used standard settings to set it up automatically.

As far as I know, I don't need to do any further customiseation/changes on cloudflares end?

I then used the CLI method to transfer both data, and attachments from my local server to cloudflare. Using the CLI method by DP, I did find it odd that when selecting data / internal data - it didn't ask for which bucket it was supposed to transfer to? I'm assuming this is automatic, as it appears that both buckets were filled and have their respective data inside. E.g. Checking the data bucket, I have various data folders and in the attachments bucket, I have attachments.

Viewing my DNS records, an entry appears to have been added -

1708616983615.webp

The warning next to R2 just states that it's not covered by a cert.

When viewing my site/forum, an attachment url (after right clicking an image) appears as - https://www.behind-the-mask.net/attachments/1684330944127-png.1055/

A style image appears to load a url from https://www.behind-the-mask.net/styles/xenbase/branding/icons/7-jacksons.png

I'm not really sure what I'm doing wrong?

Additional context -

1708617375761.webp

1708617408662.webp

Settings in first page of addon -

1708618547920.webp

Thank you in advance :)
 
Last edited:
In addition, I'm also getting these stack trace errors -

Code:
ErrorException: Cloudflare: Server error: `HEAD https://73b03aec48029a834652a839c59b4f2f.r2.cloudflarestorage.com/btm-data/media/551.jpg` resulted in a `500 Internal Server Error` response src/XF/Error.php:77
Generated by: Unknown account 22 February 2024 at 12:51 PM
Stack trace
#0 src/XF.php(219): XF\Error->logError('Cloudflare: Ser...', false)
#1 src/addons/DigitalPoint/Cloudflare/Traits/XF.php(165): XF::logError('Cloudflare: Ser...')
#2 src/addons/DigitalPoint/Cloudflare/Api/Cloudflare.php(710): DigitalPoint\Cloudflare\Api\Cloudflare->logError('Cloudflare: Ser...')
#3 src/addons/DigitalPoint/Cloudflare/Api/Advanced.php(749): DigitalPoint\Cloudflare\Api\CloudflareAbstract->makeRequest('HEAD', 'media/551.jpg', Array, true, 'btm-data')
#4 src/addons/DigitalPoint/Cloudflare/League/Flysystem/Adapter/R2.php(195): DigitalPoint\Cloudflare\Api\Advanced->headR2Object('btm-data', 'media/551.jpg')
#5 src/addons/DigitalPoint/Cloudflare/League/Flysystem/Adapter/R2.php(83): DigitalPoint\Cloudflare\League\Flysystem\Adapter\R2->getMetadata('media/551.jpg')
#6 src/vendor/league/flysystem/src/Filesystem.php(57): DigitalPoint\Cloudflare\League\Flysystem\Adapter\R2->has('media/551.jpg')
#7 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(430): League\Flysystem\Filesystem->has('media/551.jpg', Array)
#8 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(395): League\Flysystem\EventableFilesystem\EventableFilesystem->callFilesystemMethod('has', Array)
#9 src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php(128): League\Flysystem\EventableFilesystem\EventableFilesystem->delegateMethodCall('has', Array)
#10 src/vendor/league/flysystem/src/MountManager.php(313): League\Flysystem\EventableFilesystem\EventableFilesystem->has('media/551.jpg')
#11 src/XF/Util/File.php(257): League\Flysystem\MountManager->has('media/551.jpg')
#12 src/addons/EWR/Medio/Entity/Media.php(171): XF\Util\File::abstractedPathExists('data://media/55...')
#13 src/XF/Mvc/Entity/Entity.php(167): EWR\Medio\Entity\Media->getImage()
#14 src/XF/Mvc/Entity/Entity.php(125): XF\Mvc\Entity\Entity->get('image')
#15 internal_data/code_cache/templates/l1/s17/public/EWRmedio_medias_macros.php(118): XF\Mvc\Entity\Entity->offsetGet('image')
#16 src/XF/Template/Templater.php(828): XF\Template\Templater->{closure}(Object(SV\AdvancedBbCodesPack\XF\Template\Templater), Array, NULL)
#17 src/addons/MaZ/AMP/XF/Template/Templater.php(152): XF\Template\Templater->callMacro('EWRmedio_medias...', 'media_tile', Array, Array, Object(XF\Template\MacroState))
#18 internal_data/code_cache/templates/l1/s17/public/EWRmedio_medias_list.php(87): MaZ\AMP\XF\Template\TemplaterAbstract->callMacro('EWRmedio_medias...', 'media_tile', Array, Array)
#19 src/XF/Template/Templater.php(1655): XF\Template\Templater->{closure}(Object(SV\AdvancedBbCodesPack\XF\Template\Templater), Array, NULL)
#20 src/addons/MaZ/AMP/Traits/Templater/XF22.php(52): XF\Template\Templater->renderTemplate('EWRmedio_medias...', Array, true, NULL)
#21 src/addons/MaZ/AUN/XF/Template/Templater.php(39): MaZ\AMP\XF\Template\Templater->renderTemplate('public:EWRmedio...', Array, true, NULL)
#22 src/XF/Template/Template.php(24): MaZ\AUN\XF\Template\Templater->renderTemplate('public:EWRmedio...', Array)
#23 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render()
#24 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('EWR\\Medio:Media...', 'public:EWRmedio...', Array)
#25 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#26 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#27 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#28 src/XF/App.php(2487): XF\Mvc\Dispatcher->run()
#29 src/XF.php(524): XF\App->run()
#30 index.php(20): XF::runApp('XF\\Pub\\App')
#31 {main}
Request state
array(4) {
  ["url"] => string(44) "/media/?keywords=1094.200.186.782.77.192.204"
  ["referrer"] => string(71) "https://www.behind-the-mask.net/media/?keywords=1094.200.782.77.192.186"
  ["_GET"] => array(1) {
    ["keywords"] => string(27) "1094.200.186.782.77.192.204"
  }
  ["_POST"] => array(0) {
  }
}

Any ideas? Thank you again :)
 
So, this is the screenshot from the r2 interface in acp -

View attachment 298666

I set up a data bucket, and attachment bucket. I added the buckets then to the r2 interface within acp, and selected the correct buckets for each one. I used standard settings to set it up automatically.

As far as I know, I don't need to do any further customiseation/changes on cloudflares end?
Looks fine to me. And no, you don't need to do anything extra on Cloudflare's side.

I then used the CLI method to transfer both data, and attachments from my local server to cloudflare. Using the CLI method by DP, I did find it odd that when selecting data / internal data - it didn't ask for which bucket it was supposed to transfer to? I'm assuming this is automatic, as it appears that both buckets were filled and have their respective data inside. E.g. Checking the data bucket, I have various data folders and in the attachments bucket, I have attachments.
You don't have to tell it which bucket, because it already knows (from your admin settings when you setup the buckets).

Viewing my DNS records, an entry appears to have been added -

View attachment 298668

The warning next to R2 just states that it's not covered by a cert.
I'm not sure what that is... Are you using a custom certificate for your zone? If so, maybe you need to update your SSL cert to include that subdomain? I double checked my zones and they don't have that warning on the R2 DNS entries, but I also use the automatic Cloudflare SSL certs (I don't use the Advanced Certificate options).

You can check the Edge Certificates for your zone here:



When viewing my site/forum, an attachment url (after right clicking an image) appears as - https://www.behind-the-mask.net/attachments/1684330944127-png.1055/
That's normal... the application (XenForo) fetches content that are within the internal-data abstracted file system and relays them since it needs to do permission checking for access to things inside internal-data (for example checking permissions to see if the user is allowed to view that particular attachment).


A style image appears to load a url from https://www.behind-the-mask.net/styles/xenbase/branding/icons/7-jacksons.png

I'm not really sure what I'm doing wrong?
You will want to check with whoever made the style. the styles directory is not part of XenForo's abstracted filesystem so that's not going to move to a different filesystem (R2 in this case). Only the data and internal_data directories are part of XenForo's abstracted filesystem. Moving stuff from style to data is something you would want to talk to the style developer about.


Additional context -

View attachment 298669

View attachment 298670

Settings in first page of addon -

View attachment 298671

Thank you in advance :)
Honestly, it seems like it's working as expected when I visit your site. Is the worry that it's somehow not working?
 
Do you think it could work by enabling only APO?
Well, I don’t know what “it” is, but probably not either way because APO is for WordPress. And APO sucks for even what it’s designed for. I wouldn’t use APO on a WordPress site (the only type of site it’s designed for) even if someone paid me to do it.
 
Well, I don’t know what “it” is, but probably not either way because APO is for WordPress. And APO sucks for even what it’s designed for. I wouldn’t use APO on a WordPress site (the only type of site it’s designed for) even if someone paid me to do it.
I was asking because on the second-level domain (wordpress) there's APO and it works well, APO is also enabled on third-level domains, namely forum.domain.com, and it costs only $5 per month.
 
Last edited:
Well, this isn’t WordPress, there is no APO addon for XenForo, so even if you wanted to, you couldn’t use APO with XenForo.

That being said, APO is terrible even on the platform it’s for (WordPress), I wouldn’t use it on WordPress even if it was free. Enable “Guest page caching” in this addon to do the same thing as APO (but better). Same with WordPress, use the WordPress version of this addon and enable guest page caching. That’s going to be free and also work better than APO.

WordPress version:


Either way, to answer your original question, no… Cloudflare does not make an APO addon for XenForo, so even if you wanted to use APO on XenForo, you can’t.
 
Why does his have the regular URL for his attachments but your attachments have the data. domain
When viewing my site/forum, an attachment url (after right clicking an image) appears as - https://www.behind-the-mask.net/attachments/1684330944127-png.1055/

That's normal... the application (XenForo) fetches content that are within the internal-data abstracted file system and relays them since it needs to do permission checking for access to things inside internal-data (for example checking permissions to see if the user is allowed to view that particular attachment).
1710637024918.webp
 
Top Bottom