Welcome! Log In Create A New Profile

Advanced

Re: redirect to another domain based on IP address

ender ulusoy
May 07, 2019 03:46AM
Patrick, thank you. Mapping works perfect.

Today one of my developers ask me that he'll append ?domain=st when he
wants to see the staging site and ?domain=www when he wants to see the
production while testing end the end of the url. here is examples:

request goes to staging if the domain=st parameter added from office ip :
http://aaa.com/?domain=st

request goes to production even from office ip if the domain=www parameter
added
http://aaa.com/?domain=www

all requests go to staging from office ip if no domain parameter specified
https://stage.aaa.com

While other developers work fine with the solution you gave above this one
is also a qas engineer who tests the old and new site functions same time.
And wants to test functions on both sides one by one.

Can I implement a location catching in to your if clause? Will it work
inside the if block ?

Patrick <201904-nginx@jslf.app>, 6 May 2019 Pzt, 17:08 tarihinde şunu yazdı:

> On 2019-05-06 16:47, ender ulusoy wrote:
> > Main office ip 200.100.50.10
> >
> > And it's shared office. I can not setup any dns services there. All
> > the developers come from this ip.
>
> map $remote_addr $is_web_dev {
> 200.100.50.10 1;
> default 0;
> }
>
> server {
> server_name www.aaa.com;
>
> if ($is_web_dev) {
> return 301 http://stage.aaa.com$uri ;
> }
> # rest of normal prod config
>
>
> This config is probably going to cause something to blow up in the
> future because it is not doing what the user requested -- if the user
> wanted staging they should have just used http://stage.aaa.com in the
> first place.
>
>
> Patrick
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>


--
um Gottes Willen!
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

redirect to another domain based on IP address

ender ulusoy May 06, 2019 05:12AM

Re: redirect to another domain based on IP address

Patrick May 06, 2019 06:24AM

Re: redirect to another domain based on IP address

ender ulusoy May 06, 2019 09:20AM

Re: redirect to another domain based on IP address

Patrick May 06, 2019 09:46AM

Re: redirect to another domain based on IP address

ender ulusoy May 06, 2019 09:48AM

Re: redirect to another domain based on IP address

Patrick May 06, 2019 10:10AM

Re: redirect to another domain based on IP address

ender ulusoy May 07, 2019 03:46AM

RE: redirect to another domain based on IP address

Reinis Rozitis May 06, 2019 07:18AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 206
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready