Block users with empty user agent

Hi, guys!
Please help, how to block users with empty user agent at caddy server?

One trick would be to use a rewrite to direct a request with an empty User-Agent to a path that you can then explicitly forbid.

rewrite {
  if {>User-Agent} is ""
  to /no-user-agent-forbidden
status 403 /no-user-agent-forbidden

This should result in an empty message body with Status 403.

1 Like

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