Nginx reverse proxying for regions

时间:2017-06-15 10:11:32

标签: nginx load-balancing reverse-proxy

Can we use nginx reverse proxy features to delegate the request per region basis: e.g.

Client Request(EUROPE)->NGINX(http://my.app.com)->HOST(EUROPE)
Client Request(APAC)->NGINX(http://my.app.com)->HOST(APAC)

If someone can guide me or provide some meaningful example it would be fo great help.

Best

1 个答案:

答案 0 :(得分:1)

检查nginx geoip模块。

您可以做的是为目标区域(欧洲,亚洲等)创建上游,并将特定国家/地区代码或更好的大陆(欧盟,北美等)映射到这些上游。

这样的事情:

map $geoip_city_continent_code $upstream {
    EU      eu_backend;
    NA      na_backend;
}

...

upstream eu_backend {
    zone zone_eu 128k;
    server xx.xx.xx.xx:yyyy;
}

upstream na_backend {
    zone zone_na 128k;
    server xx.xx.xx.xx:yyyy;
}
...

`