# this location shows captcha
location = /antirobot {
    internal;

    proxy_connect_timeout 2ms;
    proxy_send_timeout 2ms;
    proxy_read_timeout 5ms;

    antirobot_request off;

    include /etc/nginx/conf.d/antirobot_hidecookie;

    proxy_set_header X-Antirobot-Service-Y "passport";
    proxy_set_header X-Antirobot-MayBanFor-Y 1;
    proxy_set_header X-Host-Y $host;
    proxy_set_header X-Forwarded-For-Y $remote_addr;
    proxy_set_header X-TLS-Cipher-Y $ssl_cipher;
    proxy_set_header X-Yandex-HTTPS "yes";
    proxy_set_header X-Yandex-Ja3 $http_ssl_ja3;
    proxy_set_header Connection "";
    proxy_set_header Host "antirobot.yandex.ru";
    proxy_http_version 1.1;

    proxy_pass http://antirobot$altered_uri$is_args$altered_args;
}

# this location does not show captcha
location = /nocaptcha-antirobot {
    internal;

    proxy_connect_timeout 2ms;
    proxy_send_timeout 2ms;
    proxy_read_timeout 5ms;

    antirobot_request off;

    include /etc/nginx/conf.d/antirobot_hidecookie;

    proxy_set_header X-Antirobot-Service-Y "passport";
    proxy_set_header X-Antirobot-MayBanFor-Y 0;
    proxy_set_header X-Host-Y $host;
    proxy_set_header X-Forwarded-For-Y $remote_addr;
    proxy_set_header X-TLS-Cipher-Y $ssl_cipher;
    proxy_set_header X-Yandex-HTTPS "yes";
    proxy_set_header X-Yandex-Ja3 $http_ssl_ja3;
    proxy_set_header Connection "";
    proxy_set_header Host "antirobot.yandex.ru";
    proxy_http_version 1.1;

    proxy_pass http://antirobot$altered_uri$is_args$altered_args;
}

location ~ "^/(checkcaptcha|showcaptcha|captchaimg|captcha.*)" {
    proxy_hide_header X-ForwardToUser-Y;
    proxy_set_header X-Antirobot-Service-Y "passport";
    proxy_set_header X-Host-Y $host;
    proxy_set_header X-Forwarded-For-Y $remote_addr;
    proxy_set_header X-TLS-Cipher-Y $ssl_cipher;
    proxy_set_header X-Yandex-HTTPS "yes";
    proxy_set_header Connection "";
    proxy_set_header Host "antirobot.yandex.ru";
    proxy_http_version 1.1;

    proxy_pass http://antirobot;
}
