http://test.local {
rewrite {
if {>Referer} not test.local
status 403
}
}
2017/01/29 22:23:48 /etc/caddy/caddy.conf:60 - Parse error: Wrong argument count or unexpected line ending after 'status'
Correction. {>Referer} is the full url. So we must use regex and check if it start with our site. Otherwise we will miss urls like : βhttp://example.com/http://test.localβ
http://test.local {
root /var/www/test/
rewrite {
if {>Referer} not ""
if {>Referer} not_match ^http:\/\/test\.local
to /hotlink
}
status 403 /hotlink
}
if {>Referer} not "http://test.local/" will stop requests refered by both http://example.com/http://test.local/ and http://test.local/test, for example. Itβs an exact match (opposite of is).
if {>Referer} not_has "http://test.local/" will NOT stop a request refered by http://example.com/http://test.local. The likelihood of that happening in normal browser behaviour is incredibly unlikely, however.
Check out the rewrite docs for specific conditional behaviour.