Categories
Mastering Development System & Network

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

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

This is what I am trying to do but it does not seem to work. Where have I gone wrong?

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

Leave an answer

Your email address will not be published. Required fields are marked *