O
O
OKNOZA2015-06-23 02:42:32
Nginx
OKNOZA, 2015-06-23 02:42:32

How to leave those browsers that you need in $http_user_agent under nginx?

There is such a code.

if ($http_user_agent ~* msnbot|scrapbot) {
        return 403;
    }

It screens out normally, but how to do the opposite, prescribe the browsers and tablets that are, and all the other Mimi pass? 403 issue if not in the list?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nazar Mokrinsky, 2015-06-23
@nazarpc

You in the documentation, not here.
Try it!:

if (!$http_user_agent ~* msnbot|scrapbot) {
        return 403;
}

V
Vlad Zhivotnev, 2015-06-23
@inkvizitor68sl

if ($http_user_agent !~* msnbot|scrapbot) {
        return 403;
}

nginx.org/ru/docs/http/ngx_http_rewrite_module.html#if

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question