M
M
Magic_Moment2020-07-20 15:14:40
Nginx
Magic_Moment, 2020-07-20 15:14:40

How to deny access to a site from USA but allow user-agent Googlebot?

All the best!
GNU/Linux Ubuntu 18.02 has LEMP installed (NGINX 1.14.0).

There is a need to block certain countries (for example, the USA and China), but allow access to the Google robot, which is located in the states.

How to write rules in NGINX configs so that using the NGINX GeoIP module you can block countries without catching certain user-agents?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-07-20
@dodo512

map "$geoip_country_code,$http_user_agent" $deny {
    default           0;
    ~^US.*Googlebot   0;
    ~^US              1;
    ~^CN              1;
}

server {
    if ($deny) {
        return 403;
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question