referer-restriction
Allows or denies requests by their Referer header.
referer-restrictionPriority 2990What it does
referer-restriction lets a request go on to the route's backend or refuses it by the host in its Referer header, the page that sent the client. With Allow these referers every host outside Whitelist is refused, with Deny these referers every host on Blacklist. A refused request is answered 403 with Your referer host is not allowed unless you set Message.
A request that carries no Referer at all, a direct visit or a link opened from an app, is refused unless Bypass missing is on. The header is whatever the client chooses to send, so the plugin keeps other sites from linking to you, not callers who write the header themselves.
When to use it
- Images or files your own sites show, which other sites should not link to directly.
- A route your pages on
example.comand its subdomains call, with direct visits still let through. - One site that links to your content without leave,
scraper.example.comfor example, refused with a message of your own while everyone else passes.
Not for judging the address a request arrives from — see ip-restriction (Allows or denies clients by IP address or CIDR range), judging the client software by its User-Agent header — see ua-restriction (Allows or denies clients by their User-Agent) or refusing requests by their path — see uri-blocker (Blocks requests whose URI matches a rule).
Set it up
Allow requests linked from your own sites and direct visits
Choose Allow these referers, fill Whitelist as in the JSON below and turn on Bypass missing.
{
"whitelist": [
"example.com",
"*.example.com"
],
"bypass_missing": true
}
More scenarios
Refuse requests linked from a named site
Choose Deny these referers, fill Blacklist as in the JSON below, turn on Bypass missing and set Message to This content cannot be linked from that site..
{
"blacklist": [
"scraper.example.com"
],
"bypass_missing": true,
"message": "This content cannot be linked from that site."
}
Things to know
- Whitelist — With
example.comand*.example.comin the list, links fromhttps://example.com/startandhttps://shop.example.com/cartpass, and a link fromhttps://other.example/pageis answered403. - Whitelist — A leading star matches only longer names: *.example.com takes deep.example.com but not example.com itself. A bare star takes every host.
- Whitelist — An entry is a host name alone. One that carries a scheme,
https://app.example.comfor example, is refused when you save. - Whitelist — An entry that carries a path,
app.example.com/ordersfor example, is refused when you save. - Whitelist — An entry that carries a port,
app.example.com:8443for example, is refused when you save: the host is compared without its port. - Blacklist — With
scraper.example.comin the list, a link fromhttps://scraper.example.com/pageis answered403with your Message, and a link fromhttps://www.example.com/pagepasses. - Blacklist — A leading star matches only longer names: *.example.com takes deep.example.com but not example.com itself. A bare star takes every host.
- Bypass missing — On, a request with no
Refererpasses with either list. - Bypass missing — On, a request with no Referer, or one that is not a URL, is let through. Off, it is refused with either list.
- One copy of the plugin holds one list: Whitelist and Blacklist together are refused when you save.
- AdviceKeep referer-restriction for links between sites. Where a route must stay closed to anyone who can write a header, sign callers in with key-auth on the same route.
Settings
The fields as the console shows them, section by section.
Choose one:
Allow these referers
whitelistarray of stringsRequiredDeny these referers
blacklistarray of stringsRequiredbypass_missingbooleandefault falsemessagestringdefault Your referer host is not allowed