Welcome! Log In Create A New Profile

Advanced

Issue with Upstream servers & GeoIP

Alex
March 25, 2014 10:26PM
I am diverting traffic from one specific country (XX) to a specific APP
server (Server for country XX) using an upstream definition and geoip. See
definition below.

Everything works well except when people who live in country XX try to
access information that is hosted in the other server - this is because
they may get the URI by doing searching on Google or other search engine.
So we are trying to set Nginx so that if we get a URI that is hosted in
the other server, the user from country XX can still access it. See the
"FUN" location definition.

The problem comes when the person located in country XX sees the
domain.com/fun uri. Then, he/she gets all the text, but any reference of
css, jpegs are served by server from country XX, not by the standard
server that contains the :fun" information. How can I set it so that is
being accessed be served entirely by the appropriate server that hosts the
information?

Here is a partial definition of my nginx.conf file


##
# GeoIP Settings
##
geoip_country /pathto/GeoIP.dat;

#CREATE A MAP FOR GEOTARGET SESSIONS WITH GEOIP COUNTRY CODE
map $geoip_country_code $backend {
default default;
XX XX;
}

# SERVER DEFINITIONS

#UPSTREAM SERVERS ONE FOR STANDARD SITE & OTHER FOR SOCIAL NETWORK

upstream default.backend {
server 192.192.192.192:80; #Standard Server for all countries
}
upstream XX.backend {
server 193.193.193.193:80; #Server for country XX.
}


server {

listen 80;
server_name domain.com;

#FOR PEOPLE WHO LIVE IN COUNTRY XX WHEN THEY ACCESS anything with fun on
the URI we should let the default server handle the requests.
location ^~ /fun/ {
proxy_pass http://default.backend$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}


location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://$backend.backend;

}

}

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Issue with Upstream servers & GeoIP

Alex March 25, 2014 10:26PM

Re: Issue with Upstream servers & GeoIP

Maxim Dounin March 26, 2014 07:06AM

Re: Issue with Upstream servers & GeoIP

Alex March 26, 2014 05:56PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 76
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready