user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
geo $remote_addr $geo {
default 0;
#10.0.0.0/24 3;
10.0.0.65/32 2;
10.0.0.66/32 1;
10.0.0.63/32 3;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html/html;
index index.html;
location / {
if ($geo = 3) {
#return 403;
return 200 'this is for 10.0.0.63';
}
if ($geo = 2) {
return 200 'this is for 10.0.0.65';
}
if ($geo = 1) {
return 200 'this is for 10.0.0.66';
}
}
}
}