user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
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;
    server_tokens off;

    keepalive_timeout  65;

    # ── AI bot User-Agent map ──────────────────────────────────────────
    # Must be inside http {}, NOT inside server {} or location {}
    map $http_user_agent $bad_bot {
        default          0;       # allow everything by default
        ~*GPTBot         1;
        ~*ChatGPT-User   1;
        ~*ClaudeBot      1;
        ~*Claude-Web     1;
        ~*anthropic-ai   1;
        ~*CCBot          1;
        ~*Google-Extended 1;
        ~*PerplexityBot  1;
        ~*Amazonbot      1;
        ~*Bytespider     1;
        ~*YouBot         1;
        ~*Applebot       1;
        ~*DuckAssistBot  1;
        ~*meta-externalagent 1;
        ~*MistralAI-Spider 1;
        ~*oai-searchbot  1;
    }

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