Was this article helpful?
Thanks for your feedback
Images or assets served using Contentstack contain “contentstack.io” in the URL (i.e., https://images.contentstack.io/v3/assets/blt8b...). Many of our customers prefer to use their own domain instead by masking Contentstack’s URL.
'Masking' is the process where the end-user gets an impression as if the content is being delivered directly from the client instead of Contentstack. To do this, a proxy can be set up, however, we do not recommend setting up a proxy, as it not only increases the overall infrastructure overheads but also slows down the performance of content delivery.
Therefore, we strongly recommend using a CDN service such as Fastly to deliver content to the end-user quickly and efficiently.
Note: Images here refer to the usual images that we use in our content or something that has extension .png, .jpg, .jpeg, and so on. Assets refer to anything that is not images, for example, PDFs.
When the end-user of our client sends some requests to fetch assets or images, the request is not sent to Contentstack directly. Instead, the static domain that is set up on the client side, using Fastly, routes the request to Contentstack CDN endpoints images.contentstack.io and assets.contentstack.io to deliver the content.
This routing happens at the backend (discussed below) and the end-user gets an impression as if the content is delivered through the client and not directly from Contentstack.
To create proxy images.contentstack.io and assets.contentstack.io with a custom domain using Fastly, follow the below steps:
# Request Condition: images.contentstack.io Prio: 10 if( req.url ~ "\.(exr|apng|bmp|cgm|drle|emf|fits|g3|gif|heic|heics|heif|heifs|ief|jls|jp2|jpg2||jpeg|jpg|jpe|jpm|jpx|jpf|ktx|png|sgi|svg|svgz|t38|tif|tiff|tfx|webp|wmf|pti|psd|azv|uvi|uvvi|uvg|uvvg|djvu|djv|\*sub|dwg|dxf|fbs|fpx|fst|mmr|rlc|ico|mdi|wdp|npx|tap|vtf|wbmp|xif|pcx|3ds|ras|cmx|fh|fhc|fh4|fh5|fh7|\*ico|jng|sid|\*bmp|\*pcx|pic|pct|pnm|pbm|pgm|ppm|rgb|tga|xbm|xpm|xwd)$" ) { set req.backend = F_images_contentstack_io; # Header rewrite images.contentstack.io : 10 set req.http.host = "images.contentstack.io"; #end conditionIn the above condition, any URL that ends with 'image type', the request is directed to 'images.contentstack.io', as depicted in the following diagram:
# Request Condition: assets.contentstack.io Prio: 10 if( req.url !~ "\.(exr|apng|bmp|cgm|drle|emf|fits|g3|gif|heic|heics|heif|heifs|ief|jls|jp2|jpg2||jpeg|jpg|jpe|jpm|jpx|jpf|ktx|png|sgi|svg|svgz|t38|tif|tiff|tfx|webp|wmf|pti|psd|azv|uvi|uvvi|uvg|uvvg|djvu|djv|\*sub|dwg|dxf|fbs|fpx|fst|mmr|rlc|ico|mdi|wdp|npx|tap|vtf|wbmp|xif|pcx|3ds|ras|cmx|fh|fhc|fh4|fh5|fh7|\*ico|jng|sid|\*bmp|\*pcx|pic|pct|pnm|pbm|pgm|ppm|rgb|tga|xbm|xpm|xwd)$" ) { set req.backend = F_assets_contentstack_io; # Header rewrite assets.contentstack.io : 10 set req.http.host = "assets.contentstack.io"; #end conditionThe working of the above condition is depicted in the following diagram:
Was this article helpful?
Thanks for your feedback