nginx: how to redirect depending on a range of IP addresses?


I am trying to make a site only accessible from the local network and people on the external network will get a static page that says some other message.

This is what I'm trying to do, but it doesn't seem to work. Where did I go wrong?

         if ($remote_addr != 192.168.1.0/24) {
                   rewrite ^/* /covid19 last;
         }