Как заблокировать пустые пользовательские агенты в nginx?

Я пытаюсь глобально заблокировать доступ пустых пользовательских агентов к сайтам на сервере. Я добавил запрет http_user_agent, но он не работает вообще. Я делаю это правильно ..? Вот мой nginx.conf:

#user  nginx;
worker_processes  1;

#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

#pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       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  0;
    keepalive_timeout  65;
    #tcp_nodelay        on;

    # enable gzip compression
    gzip on;
    gzip_min_length  1100;
    gzip_buffers  4 32k;
    gzip_types    text/plain application/x-javascript text/xml text/css;
    gzip_vary on;
    # end gzip configuration

    server_tokens off;

    server {
        if ($http_user_agent ~* (^$)) { return 403; }
    }

    include /etc/nginx/conf.d/*.conf;
}

Ответы на вопрос(2)

Ваш ответ на вопрос