Cloudflare Setup
Last updated
Last updated
If Cloudflare is used as a proxy for your domain, you will need to adjust some settings when using Smoxy.
If you have activated the conversion to WebP and/or AVIF in your site configuration, you must deactivate image optimization in Cloudflare.
This option is only available when using a Pro or Business account in Cloudflare.
Cloudflare does not check the Content-Type of images stored in the cache, but only the file extension. When using the conversion to WebP and/or AVIF in Smoxy, the file change remains identical, only the Content-Type header is changed. As a result, an Avif would be cached in Cloudflare with the file extension .jpg. You can define a rule for your images in the cache rules in Cloudflare.
You can copy and paste this expression into Cloudflare by clicking on the Edit expression button. Confirm the process by clicking on Use expression builder.
When using Cloudflare, there are a few things to keep in mind regarding cache invalidation.
Usually, no additional configuration is needed in Cloudflare for BAN requests. However, this may vary depending on the implementation of the application's cache invalidation.
Cloudflare is renowned for its DDoS protection and automatically blocks requests from sources that make a particularly high number of requests to the website.
If your application invalidates the cache, sending several thousand requests to smoxy, this traffic typically passes through Cloudflare. At this point, Cloudflare might perceive the application's BAN requests as a DDoS attack and block them.
If the application sends PURGE requests, Cloudflare automatically blocks them, and there is no way to configure the Web Application Firewall to allow PURGE requests.
If Cloudflare blocks either BAN requests due to a high volume of requests or if the application sends PURGE requests, a separate subdomain must be configured in both cases. Unfortunately, the rules in Cloudflare for configuring the Web Application Firewall do not provide a reliable way to handle these requests.
Does the subdomain need to be configured in smoxy?
If the main domain has already been set up in smoxy and assigned to a site, all incoming requests from subdomains are automatically routed through the site of the main domain.
In this case, the domain smoxy.mydomain.com
is directly routed to the Prod
site, where it will clear the cache as requested by the request.
By configuring a subdomain, the Cloudflare proxy can be disabled , and the traffic can be forwarded to smoxy. This way, no more blocks occur, and cache invalidation can proceed normally.