URL signing
What is URL signing
URL signing can use keys to protect your files from unauthorized access.
How to configure URL signing
You can enable URL Signing in CDN Resources ->Safety Protection ->Access Protection.
And fill in your own generated URL signature, of course, you can also choose to have the platform automatically generate it.
URL signing example
A URL signature key is similar to a password and can contain a minimum of 6 to a maximum of 32 characters. The following is an example of a signature URL in one of the following formats:
Query string format
http://example.com/filename?secure=DMF1ucDxtqgxwYQ&expires=1546300800&ip=1.2.3.4
Path format
http://example.com/secure=DMF1ucDxtqgxwYQ&expires=1546300800&ip=1.2.3.4/filename
The format of this protection token is as follows:
<expires><path><key><ip>
expires : The expiration of the URL. This is in Unix timestamp format. This is optional.
path: The file path or file directory **note: for HLS, it is better to put path instead of .m3u8 file, so that all the chunk of the hls will be authenticated as well.
key: The URL signing key. Size of the key is between 6 characters to 32 characters.
IP: The IP that allow to access. This is optional and only one IP allowed when generating the hash key each time.
For generating the hash key, kindly download the attached script in Ruby, Python, PHP or Java. You may run it with the following command to generate signed URL:
Ruby:
ruby UrlSigning.rb -f path -s https -r example.com -p images/photo.png -k abc123 -e 1546300800 -i 1.2.3.4
Python:
python UrlSigning.py -f path -s https -r example.com -p images/photo.png -k abc123 -e 1546300800 -i 1.2.3.4Python3:python3 UrlSigning3.py -f path -s https -r example.com -p images/photo.png -k abc123 -e 1546300800 -i 1.2.3.4
Python3:
python3 UrlSigning3.py -f path -s https -r example.com -p images/photo.png -k abc123 -e 1546300800 -i 1.2.3.4
PHP:
php UrlSigning.php -f path -s https -r example.com -p images/photo.png -k abc123s -e 1546300800 -i 1.2.3.4Java:javac UrlSigning.javajava UrlSigning -f path -s https -r example.com -p images/photo.png -k abc123 -e 1546300800 -i 1.2.3.4
Java:
javac UrlSigning.java
java UrlSigning -f path -s https -r example.com -p images/photo.png -k abc123 -e 1546300800 -i 1.2.3.4
Available options:
-f: format, path or querystring, default = querystring
-s: scheme for resource URL, http or https, default = http
-r: resource hostname (compulsory)
-p: file path of the resource, default = /
-k: URL signing key (compulsory) -e: expiration of the URL (optional)
-i: IP that allow to access (optional)