mod_hotlinkOverviewmod_hotlink module is aimed at protecting your web server from people stealing your traffic by directly linking to the content on your server. This is especially important for those having image, video, documents archives and other downloadable content. After enabling
Quick startLink protection methodLink protection is completely independent onReferer header and offers most comprehensive protection.
When the user requests
Referer protection methodThe task is to protect all images from hotlinking; allow referers from your own site and empty referers.
Redirect protection methodRedirect method is usually used to protect .pdf and .swf files as Internet Explorer sets incorrectReferer header for such filesor when the user clicks "Save As�" and usage of Link protection is not convenient.
Related articles and topics
Protection methodsmod_hotlink offers three protection methods each having it's advantages and peculiarities:LINKThis is the most comprehensive and powerful protection method. In this modemod_hotlink edits each link to protected content on your site by adding special cryptographic signature.
You specify expiration time for the signature on the expiry of which link becomes invalid (e.g. 30 minutes after it was requested).
LINK method is not sensitive to HTTP Referer modifications, disabled cookies or JavaScripts in user’s browsers. mod_hotlink
in LINK mode is capable of protecting any file types including streaming media and embedded content.
Starting from 3.0 version of Ape mod_hotlink is capable to add digital signature
to the links on the fly, with no need to modify HTML content.
REFERERSimply checks HTTPReferer header and rejects all requests to the protected content from unknown sites. You may use white and black lists based on Referer and User-Agent values to allow friendly sites requests and protect against some ugly hacks. This method does not require any configuration or modification to your site and is a convenient way to protect image archives.
REDIRECTChecksReferer header value but performs a redirect to a temporary signed link instead of returning content. It may be difficult to understand the theory of this method, but the only thing you need to know is that it provides moderate protection level to preserve some embedded content that cannot be protected by REFERER method - content like PDF files, Flash and Media Player movies, audio and so on. Just as in the previous method you don’t have to change anything - just enable mod_hotlink and specify a protection folder.
Enviroment variables
Directives
HotlinkProtectHotlinkProtect directive enables hotlink protection for /location_to_be_protected context using ProtectionType method. You will need at least one HotlinkProtect directive to enable protection with minimum configuration. Syntax
Description
Flags
Example
HotlinkAllowHotlinkAllow directive defines a white list record to explicitly allow requests from specific referrers, User-Agents and IPs and to bypass protection. Syntax
Note! You may have several HotlinkAllow directives in one context. They are processed top-down until the first match. So it's advisable to use more general patterns after more specific ones. Example
HotlinkDenyHotlinkDeny directive defines a black list record to explicitly prohibit requests from specific referrers, User-Agents and IPs. Syntax
Note! You may have several HotlinkDeny directives in one context. They are processed top-down until the first match. So it's advisable to use more general patterns after more specific ones. Example
HotlinkExpiresHotlinkLinkExpires directive sets the time during which the signature is valid and thus may be used. Syntax
HotlinkInvolveIPHotlinkInvolveIP directive defines whether the client IP address is used for signature generation. This makes digital signature to be IP-related, thus clients with different IP addresses will be unable to download content using same signatures. Syntax
Default
HotlinkSignatureHotlinkSignature directive specifies the password that will be used for signature encryption. If not set explicitly, the random password will be generated automatically upon each application start for better security. This parameter is only needed when you need to share links between different servers, like in cluster. You just set identical signatures for all servers and synchronize time which makes links generated on one server to be valid on another. Syntax
Default
Advanced usageUsing environment variables to enable hotlink protectionAll mod_hotlink settings may be defined using
Manual signature useFor any protection type and for each request mod_hotlink generates a unique signature that is then saved in HOTLINKBLOCKER_SIGNATURE server variable. It may be extracted manually in the following manner:
This allows to use it in locations where mod_hotlink can't fix links by itself, e.g. in Flash scenarios, JavaScripts etc.
How it worksLink protection methodLink protection is completely independent on
When the user requests default.html mod_hotlink replaces links in the tag with specifically generated sequence:
How it works:
Referer protection methodThe task is to protect all images from hotlinking; allow referers from your own site and empty referers.
How it works: When a browser makes a request, it passes Say you have a page
Note! If you directly put the address of the resource
into the browser address bar (e.g.
Redirect protection methodRedirect method is usually used to protect .pdf and .swf files as
Internet Explorer sets incorrect
How it works:
All this stuff is necessary to bypass noncompliance of some browsers with the standards
(especially this refers to Internet Explorer) as they sometimes don't
set |