radar2go / radar-beta

This is a public repo meant to collect issue reports on radar2go
1 stars 0 forks source link

Allow webapp only in Serbia #39

Closed mturjak closed 8 years ago

mturjak commented 8 years ago

Recompile nginx with GeoIP module enabled and configure to redirect to generic landing page outside Serbia, but to load the webapp in serbia.

mturjak commented 8 years ago

Recompile nginx with the GeoIP module (after also installing the geoip library). Then configure nginx to redirect if country code not allowed.

## configure nginx make file
./configure --add-module=/opt/nginx-upload-module --add-module=/opt/nginx-upload-progress-module --sbin-path=/usr/local/sbin --with-http_ssl_module --with-http_geoip_module

## download GeoIP database if changed
sudo wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
sudo mv GeoIP.dat /usr/local/share/GeoIP/

## add to nginx.conf
# - in http block
geoip_country /usr/local/share/GeoIP/GeoIP.dat;
map $geoip_country_code $allowed_country {
    default no;
    SR yes;
}
# - in location block
if ($allowed_country = no) {
    return 301 https://radar2go.com;
}

and modify angularjs app.js routeProvider setup to redirect to empty root:

// in $routeProvider setup
.otherwise({
    redirectTo: '',
    templateUrl: 'partials/home.html',
    controller: 'AppCtrl'
});