redirect to another domain based on IP address

Reinis Rozitis r at
Mon May 6 11:17:48 UTC 2019

> We have a website under heavily development. So we divide the site to 3 branches stage, demo and main. What our developers want from me is : "every request from office ip address to main domain must redirect to stage." 

If there is a single IP you can use the if directive ( ) in case of multiple - map ( ) or geo will be a better approach.

A generic example with if:

if ($remote_addr = {
        return 301$request_uri;


More information about the nginx mailing list