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! 👉
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.
This document provides instructions and configurations to set up an NGINX reverse proxy that:
X-Forwarded-For
and X-Real-Ip
ngx_http_sub
and ngx_http_proxy
modules to be enabled. They are usually installed by default.server_name
and sub_filter
directives./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.Please note that the Privacy Controls and Cookie Solution native country detection (parameter countryDetection:true
) won’t work with this configuration and the location of the end-user will always be considered as the one of the server where the reverse-proxy is installed is located.
If you are using different settings based on the location of your users, you will have to rely on your own geolocation system to load the correct configuration.
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
inactive=180m;
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 "";
}
}
If you’re using our SDK, in order to use your reverse proxy setup, you can follow these configuration examples:
For Android:
IubendaCMPConfig config = IubendaCMPConfig.builder()
.siteId("XXXXX") //use your siteId
.cookiePolicyId("YYYYY") //use your cookiePolicyId
.proxyUrl("https://iubenda.example-client-domain.com/cs/mobile.htm") //use your own reverse-proxy URL
.build();
For iOS:
let config = IubendaCMPConfiguration()
config.siteId = "XXXXX" //use your siteId
config.cookiePolicyId = "YYYYY" //use your cookiePolicyId
config.proxyUrl = “https://iubenda.example-client-domain.com/cs/mobile.htm" //use your own reverse-proxy URL
IubendaCMP.initialize(with: config)
Please note that this configuration is available from version 2.6.0 of our SDK (for both Android and iOS).
Please reach out to us via email at business@iubenda.com if you need any further assistance or clarification. We’re happy to help.