edit

System Integration

CDN Integration

How To Integrate LeoFS With CDN

There is nothing special to do for integrating LeoFS with CDN1. Since almost CDN service providers take care of a CacheControl Header received from an origin to determine how long a file should be cached on their edge servers, so if you want to modify TTL according to URLs, you can do it by using http_custom_header.conf.

How To Use http_custom_header.conf

Append the following line to leo_gateway.conf which contains a LeoGateway's directory. Arrange the http_custom_header.conf into the path specified at leo_gateway.conf.

1
2
## HTTP custom header configuration file path
http.headers_config_file = ./etc/http_custom_header.conf

How To Write http_custom_header.conf

The syntax is a subset of Nginx2 configuration. You can use location contexts to specify TTL and add any headers to the path.

1
2
3
4
5
location bucket/static {
    expires    12h;
    add_header Cache-Control public;
    add_header X-OriginalHeader OriginalValue;
}

In this case, assuming that a CDN service already has been enabled, and there is a file at bucket/static/path_to_file, if a user browses that file via the CDN. The CDN will receive a response from a LeoFS system with customized Http headers.

1
2
Cache-Control: public, max-age=43200;
X-OriginalHeader: OriginalValue;

Use Cases

Specify TTL by the bucket.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
location bucket1 {
    expires    1h;
    add_header Cache-Control public;
}
location bucket2 {
    expires    1d;
    add_header Cache-Control public;
}
location bucket3 {
    expires    1h30m;
    add_header Cache-Control private;
}

Appendix

Syntax for the expire field

LeoFS supports a part of measurement units which can be used in Nginx configuration. Following time intervals can be specified.

1
2
3
4
s: seconds
m: minutes
h: hours
d: days

List of verified CDN services

LeoFS Team tested the following CDN services with LeoFS. We recognize that other CDN services also should work.