What is caddy's equivalent of ngx_http_referer_module?

Is there an equivalent of ngx_http_referer_module?

The ngx_http_referer_module module is used to block access to a site for requests with invalid values in the “Referer” header field.

http://nginx.org/en/docs/http/ngx_http_referer_module.html

Or any way of doing a similar protection in caddy without a module?

Reading the documentation you linked, it looks like the module:

  1. Reads the Referer header of an incoming request
  2. Blocks requests with unwanted values

We can do #1 with Matchers and #2 with respond.

Specifically, you’re looking for the header matcher and you probably want to send perhaps a status 403.

See:
https://caddyserver.com/docs/caddyfile/matchers#header
https://caddyserver.com/docs/caddyfile/directives/respond

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.