About
As a CDN Technology Partner, Cloudflare brings security and acceleration enhancements to the JetRails Hosting Platform. We picked the most relevant features for online merchants and built them directly into your Magento Administrator Control Panel. Control and modify these powerful features without leaving your store’s admin portal: Global CDN Passthrough, DDoS Mitigation, Cache Purge, JS Minification and Image Optimization, and many more. This extension supports both Magento 2 Open Source (CE) and Adobe Commerce (EE).
The MIT license
The JetRails Magento 2 extension for Cloudflare is licensed under the MIT license. If you would like to learn more, please see the details of the MIT license.
Installation process
The installation process that we will be outlining assumes that you obtained the extension through the Magento Marketplace. You can find this extension here. First, make sure you purchase it through the marketplace (it’s free). Next you will want to obtain your Magento account’s credentials to access repo.magento.com. You can find them by going to https://marketplace.magento.com/customer/accessKeys after you already signed into your Magento account.
Next you will want to run the following commands:
composer require jetrails/magento2-cloudflare
php bin/magento setup:upgrade
php bin/magento cache:flush
Note: An additional step of logging out of your Magento backend may be required in order to refresh any altered ACL resources that the newly installed extension could have caused.
Setup process
Once the extension is installed, the Cloudflare dashboard can be found in Magento’s backend with the use of the menu by navigating to JetRails > Cloudflare Dashboard.
There you will be greeted with a configuration form which will look similar to the one found below.
In order for this extension to work, access to Cloudflare’s API must be configured. The text box labeled Zone ID should contain the store view’s domain name’s Zone ID. This can be found in Cloudflare’s dashboard.
The text box labeled API Token should contain an API token that is pre-configured with Cloudflare’s Token API. For more information about creating an API Token, please refer to Cloudflare’s documentation. See image below for recommended configuration.
Note: These credentials are not the Account API Key that is found on the same page below the API Token section.
Using the dashboard
The Cloudflare dashboard can be found by navigating to JetRails > Cloudflare Dashboard with the use of the menu in the Magento backend.
Assuming that the steps in the setup process were completed, you will be greeted with an array of tabs on the left side of the page. Otherwise, you will only be able to see the Overview tab, in which case you should go through the proper steps to setup the extension. This extension mimics as much functionality from Cloudflare as it can with more features and sections on their way.
Multi-store support
Our extension supports multi-store setups within Magento. While on the Cloudflare dashboard page, the currently selected domain name will be present to the right of the JetRails logo. When hovering over the domain name, there will be a drop-down populated with all the domain names that are present in your Magento setup. By simply clicking on the domain name you want to use, you will be able to change the scope of the dashboard to configure settings related to said domain name. Please note that this implies that setup for the new domain name is required. A new set of credentials including a Zone ID and an API Token will need to be supplied.
Restrict access using ACLs
Every card like section found under every tab of the Cloudflare Dashboard is assigned its own resource within the Magento ACL system. This means that permission to view and use every card like section can be delegated separately based on which role a user is assigned. An example case where this would be useful is if one had a developer role within the Magento ACL system, and they wanted their developer to have permission to only toggle Developer Mode, which lives under the Caching tab. The store administrator can simply achieve this by going to System > Permissions > User Roles.
They can then click on the developer role to edit it.
Once on the edit page, they can go to Role Resources and select the JetRails > Cloudflare Dashboard > Caching > Development Mode resource.
This will give all users that are assigned to that role the permission to use the Development Mode section, while restricting access to all other sections.
CLI commands
One can save Cloudflare credentials through Magento’s CLI interface. If you run the cloudflare:set-auth command with the required options --domain, --zone, and --token then it will save the passed credentials for that passed domain. Please note that these credentials are not verified and are simply set via this command. Please login to the admin backend to verify if the saved credentials can be used.
Note: The domain name that is passed must be one that is setup within your Magento installation. If an invalid one is passed, then all currently configured domains will be displayed to the user with an error message.
$ php bin/magento cloudflare:set-auth \
--domain example.com \
--zone foo \
--token bar
Successfully saved zone and token for domain example.com.
Once your credentials are saved, you have access to more helpful commands. You can always find more information about a command by passing the -h flag alongside it. The following commands are implemented:
Command |
Description |
cloudflare:set-auth | Save Cloudflare zone-id/api-token for given domain name |
cloudflare:caching:development-mode:get | Is site currently in development mode? |
cloudflare:caching:development-mode:set | Set development mode to ‘on’ or ‘off’ |
cloudflare:caching:purge-cache:everything | Purge all Cloudflare cache |
cloudflare:caching:purge-cache:url | Purge individual URL from Cloudflare cache |
cloudflare:caching:purge-cache:host | Purge hosts from Cloudflare cache |
cloudflare:caching:purge-cache:prefix | Purge prefixes from Cloudflare cache |
cloudflare:caching:purge-cache:tag | Purge tags from Cloudflare cache |
Comments
0 comments
Article is closed for comments.