Skip to content

Image Security

IIPImage is designed so that your original images never need to be directly accessible over the web: iipsrv reads them from the filesystem and streams derived tiles to clients. This page covers the controls iipsrv provides over image access, together with the web-server measures commonly used around it.

Image access

IIPImage allows you to protect your original images as they do not need to be directly accessible to a user via the web server (Apache, Lighttpd etc). A public user does not need to have download access to the full resolution image file – only the IIPImage server needs to. Images, therefore, do not need to be in the web server document root or in any subdirectory of it. The images can be stored in any directory (or even remote directory mounted via NFS or Samba etc) on the machine on which the IIPImage server iipsrv executable runs. You can also use the operating system’s access control to grant read access permission to the iipsrv process for specific directories or images only.

iipsrv also has configuration parameters that can further improve security. The FILESYSTEM_PREFIX and FILESYSTEM_SUFFIX environment parameters allow you to specify a prefix to the image path and a suffix to the file name. It is, therefore, possible to store the images at a file system location such as: /images/tiffs/

and set FILESYSTEM_PREFIX to this path, which allows public image requests to be made without any directory path. For example, for an image in /images/tiffs/image1.tif, a resulting IIIF request would simply:

http://your.server/iiif/image1.tif/full/500,/0/default.jpg

If you also set FILESYSTEM_SUFFIX to “.tif”, you will be able to simplify the request even further:

http://your.server/iiif/image1/full/500,/0/default.jpg

Paths passed to iipsrv must be absolute system paths on the server (see Image File Names), and components such as ../ are filtered out.

Path traversal and untrusted identifiers

Treat image identifiers supplied by clients as untrusted input:

  • keep originals outside the web root and readable only by the iipsrv user;
  • use FILESYSTEM_PREFIX to confine requests to a single directory tree;
  • prefer opaque identifiers (for example UUIDs) over user-supplied path fragments;
  • do not assume that a suffix such as .tif constrains the file type — iipsrv detects formats from magic file signatures.

Network isolation and proxying

The IIPImage instance can run on a separate machine to that hosting the web server front-end, adding a further level of security and, indeed, potentially improving performance. Most web servers are able to forward FCGI requests to another host. For example, to configure Apache to forward FCGI requests to the standard FCGI port on a iipsrv running on another server:

ProxyPass "/fcgi-bin/iipsrv.fcgi" "fcgi://iipsrv.host:9000/"

Note that it is only necessary to forward FCGI connections, not the full HTTP request. For more details of how to proxy, see the proxy section of the server documentation. The FastCGI port (9000 by default) should be reachable only by the web server — firewall it off from the internet. With Docker, publish only the web server port and avoid exposing the FCGI port publicly.

CORS

When a viewer is hosted on a different origin to the image server, the browser requires an Access-Control-Allow-Origin response header before it will use the tiles. The iipsrv CORS startup variable sets this header; it is not set by default.

For a fully public image service, allow all origins:

CORS="*"

To restrict requests to a particular domain instead, set the variable to that origin:

CORS="https://your.domain"

The viewer page must then be served from that exact origin — https://your.domain will not match http://your.domain, https://www.your.domain or a different port. Only one origin can be specified; for several origins, set CORS at the web server or proxy instead.

Set this wherever iipsrv’s environment variables are configured — for example, in /etc/default/iipsrv, or in Apache with FcgidInitialEnv CORS "https://your.domain". See Startup variables. The same header can alternatively be added by your web server or proxy.

CORS is a browser policy, not access control: it does not prevent non-browser clients from requesting tiles. Images that must be private need to be protected at the web-server layer.

Rate limiting and caching

Tile viewers can generate large numbers of requests. Apply rate limits at the web server, reverse proxy or CDN, and set sensible caching: iipsrv’s CACHE_CONTROL startup variable sets the HTTP Cache-Control header and defaults to max-age=86400 (24 hours). Memcached and caching proxies can further reduce load — see Server Configuration and Logging. Log files (LOGFILE, VERBOSITY) and the health endpoint are useful for spotting abuse and verifying availability.

Dynamic Watermarking

Watermark exampleThe IIPImage server is able to perform dynamic watermarking without the need to modify the source image. The watermark is dynamically added server-side to each tile that is streamed to the client with user-defined levels of transparency. It’s also possible to set a level of probability that a particular tile will have a watermark applied to it if you do not wish to have a watermark applied to every single tile. You can see a demo of dynamic watermarking in action on the demo page.

The server supports three watermarking related parameters:

WATERMARK TIFF image to use as watermark file. WATERMARK_PROBABILITY The probability that a particular tile will have a watermark applied to it. 0 means never, 1 means always. WATERMARK_OPACITY The opacity (between 0 and 1) applied to the watermark image.

The watermark file must be a TIFF image which can be greyscale or color, either 8 or 16 bit and can optionally include an alpha channel. The watermark should be not bigger than the tile size used for the source TIFF or JPEG2000 tiling (typically 256 pixels for both width and height). If bigger, the watermark will simply be cropped to the image tile size. If the watermark is smaller, the watermark will be positioned randomly within the available space. This randomness adds an extra level of security, making any automated watermark removal far more difficult. The watermark is simply added pixel by pixel to the image data, taking into account the WATERMARK_OPACITY parameter and any alpha channel included in the watermark. Thus, the watermarked image for a given pixel i:

output image[i] = source image[i] +
        ( watermark image[i] * alpha channel[i] * watermark opacity parameter )

Thus, you should avoid using white backgrounds in your watermark, unless you have a suitable alpha channel. Furthermore, your watermark logo or text should not be black (pixel value = 0) as the pixel values are added to the output. If you have trouble creating your watermark, you can download an example watermark file here.

Watermarking is a deterrent to casual copying, not an access-control mechanism.

Security checklist

  • Originals stored outside the web root and readable only by the iipsrv user
  • FILESYSTEM_PREFIX restricting requests to a single image tree
  • FastCGI port firewalled; iipsrv on a private network where possible
  • CORS restricted to known origins, or * for a fully public service
  • Rate limiting and caching configured
  • Logs and the health endpoint monitored
Copyright © 2026 Ruven Pillay. All Rights Reserved.