smoxy
English
English
  • Welcome to smoxy
  • Changelog
  • Support Contact
  • Migration of Load Balancers and Domains
  • Account
    • What is an Account?
    • Site Overview
      • Add a new domain
    • Origins & Loadbalancer
    • Domain Overview
      • SSL
    • DNS Overview
    • Team
    • IP Lists
    • Billing
  • Sites
    • What is a Site?
    • Dashboard
    • Page Rules
      • Page Rules - Use Cases
    • Conditional Rules
      • Conditional Rules - Use Cases
    • Image Optimization
    • Acceleration
    • Security
    • Basic Configuration
    • Redirect Sites
  • Developer Guide
    • GeoIP Headers (Request Metadata)
    • Cache Invalidation
    • Best Practices
      • Services Sites
      • Flush Tags
      • Test configuration options
      • Cache key configuration for images
    • Cloudflare Setup
    • Frameworks
      • Shopware 6
Powered by GitBook
On this page
  • Image optimization
  • Cloudflare caching for images
  • How to create a bypass cache rule for images
  • Cache Invalidation
  • BAN Request
  • PURGE Requests
  • Allowing BAN & Purge Requests through Cloudflare

Was this helpful?

  1. Developer Guide

Cloudflare Setup

Last updated 7 months ago

Was this helpful?

If Cloudflare is used as a proxy for your domain, you will need to adjust some settings when using Smoxy.

Image optimization

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 caching for images

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.

How to create a bypass cache rule for images

Expression

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.

// Some code(ends_with(http.request.uri.path, ".png")) or (ends_with(http.request.uri.path, ".jpeg")) or (ends_with(http.request.uri.path, ".jpg")) or (ends_with(http.request.uri.path, ".gif")) or (ends_with(http.request.uri.path, ".webp")) or (ends_with(http.request.uri.path, ".avif"))

Cache Invalidation

When using Cloudflare, there are a few things to keep in mind regarding cache invalidation.

BAN Request

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.

PURGE Requests

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.

Allowing BAN & Purge Requests through Cloudflare

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.

Cloudlfare Image Optimization settings
Cache Rule in Cloudflare
Cloudflare Cache Rule Setup
Adding a subdomain in Cloudflare
smoxy main domain