Cloudflare is a first and foremost a Web Application Firewall and Content Distribution Network, among other additional services.
Moxie.Build comes with tightly coupled Cloudflare integration for a seamless integration once configured. Upon updating public files and content management system content, Moxie.Build will automatically purge the Cloudflare cache for those resources, on both http and https URLs. In addition, on demand Cloudflare Purge menu items will show up in the Admin Files area on each file. The CFPurge MOX command provide developers with a quick and easy way to purge the CDN programmatically, and the CFApi$ MOX Top Query Function allows developers to easily tap into the entire Cloudflare API without having to manage the credentials in the code.
The Cloudflare integration requires some values to be set in the Moxie.cfg file, and some values to be set in the Setup table.
These and other advanced values are not available in the server setup window, and must be edited in the Moxie.cfg file manually. Note that the Server Setup window auto-saves the Moxie.cfg file on button clicks and on close; so don't have it open while you make manual changes to the file.
- AltIPInfo = CF-Connecting-IP
- This value allows the server to record the client-side IP address into each Request Query's Req.Addr field, and in the Moxie.log file. Note that the Moxie.log file will still show new connections as coming from a Cloudflare IP, but each request that arrives will be recorded with the client-side IP provided in this HTTP header.
- CountryInfo = CF-IPCountry
- Cloudflare provides IP based country information for free as part of their services, and this value allows the server to set the Req.Country field in the Request Query.
- This needs to be set regardless of Cloudflare for proper operation of various aspects of Moxie.Build, but note that the Cloudflare integration uses this value
- This needs to be set regardless of Cloudflare for proper operation of various aspects of Moxie.Build, but note that this is used as one component of the Cnw.CF.Key encryption. This value needs to be unique between different instances of Moxie.Build.
- This defaults to the currently support version of the Cloudflare API
- Don't touch this unless you have good reason to and understand what you are doing
- This is the email address of your Cloudflare account
- Set this to value of "y" (without the quotes) to enable automatic purging of CDS resources
- Set to a value of "-" (without the quotes) to disable
- The Cloudflare Zone ID for this host
- Get this from the domain's Overview tab, right column, API header, Zone ID
- Set this one last, since it will be encrypted with salt that includes other values
- Get this from Cloudflare's website, My Profile, API Tokens header, Global API Key, View
You can confirm that your configuration above is working via the following:
- Traffic arriving via Cloudflare should show a single socket ID (2nd tab position) as Connected from IP Address X.X.X.X that is an IP address from Cloudflare, while the HTTP(S) requests sharing the same socket ID should show the IP address of the actual end client (in the 7th tab position)
- If you edit any page in the Moxie.Build content management system and update it, you should see the log file report CFPurge (in the 3rd tab position), and "Ok" (in the 4th tab position), along with the URL that was purged (in the 4th tab position)