Answer the question
In order to leave comments, you need to log in
How to configure Nginx + geoip + gzip Depending on the city, different files with gzip compression were loaded, if they exist?
There is a URL, for example: example.com/contacts/
There is a folder /cache/contacts/
in it files, for example:
msk.html.gz
spb.html.gz
msk-obl.html.gz
len-obl.html.gz
other.html.gz
Answer the question
In order to leave comments, you need to log in
Haven't you tried it like this?
http {
...
geo $country {
default other;
127.0.0.0/24 msk;
10.1.0.0/16 spb;
192.168.1.0/24 other;
}
map $country $filename {
default other.html.gz;
msk msk.html.gz;
spb spb.html.gz;
other other.html.gz;
}
...
}
server {
...
location /contacts {
rewrite .* $filename break;
alias /var/www/server.com/cache/contacts/;
gzip on;
try_files $uri @fallback;
}
location @fallback {
fastcgi_pass 127.0.0.1:9000;
}
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question