Iubenda logo
Start generating


Table of Contents

How to prevent Ad blockers from reducing your cookie consent collection

If you rely on personalized ads to monetize your website content, ad blockers can be an issue: they can block your cookie banner and thus disrupt the collection of cookie consents.

In this guide, we will show you how to set up a CDN reverse proxy with URL substitution, avoiding the consent rate on your website being affected, and how to cache cdn.iubenda.com on a custom domain ensuring full continuity in case of iubenda CDN problems. Let’s see how to do it! 👉

Important disclaimer

This document and the included configuration are intended for expert personnel only or any person in charge of administrating the infrastructure where the proxy is being installed.

They are not intended for someone not in charge of the networking or anyone attempting to find temporary solutions or workarounds, hoping it will “just work.”

Too many possible issues could arise in the interactions with all combinations of systems and software versions, settings, and other running components to build a comprehensive guide to cover them all.

Setting up a CDN Reverse Proxy


This document provides instructions and configurations to set up an NGINX reverse proxy that:

  • Proxies static CDN contents towards cdn.iubenda.com from a custom URL (in this example: cdn.customer.com)
  • Does URL substitution in the served documents.
  • Does NOT forward the client IP with the usual headers X-Forwarded-For and X-Real-Ip
  • Serves cached assets in case the iubenda’s CDN runs into issues of any type.
  • Requires ngx_http_sub and ngx_http_proxy modules to be enabled. They are usually installed by default.
  • Use your domain of choice instead of cdn.customer.com in both server_name and sub_filter directives.
  • Add proper SSL configuration as required.
  • Make sure /tmp/cache exists and has the correct ownership: (i.e., chown nginx:nginx /tmp/cache), or change it to a location and file of choice.

Configuration Example

The configurations below are examples of a typical virtual host on Port 80. Configuration must be completed with SSL parameters, depending on the chosen settings.

# iubenda CDN local proxy configuration
# Version 1.1 - Included compression support

proxy_cache_path /tmp/cache levels=1:2 keys_zone=tmpcache:100m max_size=200m 

server {
  listen                      80;
  server_name                 cdn.customer.com;

  access_log                   /var/log/nginx/cdn-customer-access.log;
  error_log                    /var/log/nginx/cdn-customer-error.log;

  location / {
    # Link rewriting
    sub_filter 'cdn.iubenda.com' 'cdn.customer.com';
    sub_filter_types *;
    sub_filter_once off;
    # Enables compression
    gzip on;
    gzip_static off;

    # Enables cache for this location
    proxy_cache tmpcache;

    # Delivers cached stale files instead of relaying the error to the client.
    proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
    proxy_cache_background_update on;
    # Proxy cache valid for 30 min
    proxy_cache_valid 200 301 302 304 30m;
    proxy_pass https://cdn.iubenda.com/;
    proxy_set_header Accept-Encoding "";

Please reach out to us via email at business@iubenda.com if you need any further assistance or clarification. We’re happy to help.