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 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 Keys 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)