redirect to another domain based on IP address

ender ulusoy enderulusoy at gmail.com
Mon May 6 13:18:40 UTC 2019


@Patrick Thanks, here is the config I have (short version)



upstream aaa {

192.168.1.1:80;

192.168.1.2:80;

}


upstream stage {

192.168.1.3:80;

192.168.1.4:80;

}



server {

   server_name www.aaa.com;


   location / {

     add_header X-Content-Type-Options nosniff;

     add_header X-XSS-Protection "1; mode=block";

     proxy_set_header X-Real-IP $remote_addr;

     proxy_set_header Host $host;

     proxy_set_header X-Forwarded-For $remote_addr;

     proxy_pass http://aaa;

  }

}




server {

   server_name stage.aaa.com;


   location / {

     add_header X-Content-Type-Options nosniff;

     add_header X-XSS-Protection "1; mode=block";

     proxy_set_header X-Real-IP $remote_addr;

     proxy_set_header Host $host;

     proxy_set_header X-Forwarded-For $remote_addr;

     proxy_pass http://stage;

  }

}



I want if any connection request send to www.aaa.com/$request_uri from
office ip (200.100.50.1); then Nginx will redirect all requests to
stage.aaa.com/$request_uri


All other requests from the world will go www.aaa.com



On Mon, May 6, 2019, 1:23 PM Patrick <201904-nginx at jslf.app> wrote:

> On 2019-05-06 12:10, ender ulusoy wrote:
> > 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."
>
> We need more information about your architecture to be able to show you
> ways to do this.
>
> It might be more cost-effective to just chat with an engineer for hire.
>
>
> Patrick
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20190506/b21f7abf/attachment-0001.html>


More information about the nginx mailing list