server {
	listen 80;
	listen [::]:80;
	root %s/public;
	index index.php index.html;
	server_name %s;
	access_log /var/log/nginx/%s_access.log;
    error_log /var/log/nginx/%s_error.log;
	if ($http_user_agent = "Mozilla/5.0 (compatible; Adsbot/3.1)") {
		return 403;
	}

	if ($http_user_agent = "") {
		return  403;
	}

	if ($limit_bots = 1) {
	  return  403;
	}

	fastcgi_cache_key "$scheme$request_method$host$request_uri$cookie_codeAuth";
    set $no_cache 0;

    if ($request_method != GET) {
         set $no_cache 1;
    }

    if ($query_string != "") {
         set $no_cache 1;
    }

    if ($query_string != "") {
         set $no_cache 1;
    }

    set $no_cache 1;#disable cache
    add_header x-fastcgi-cache $upstream_cache_status;

    location ^~ /adminer.php {
        auth_basic           "Restricted";
        auth_basic_user_file /var/www/%s/.htpasswd;

        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php8-fpm;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
    }

	location ~ \.php$ {
          fastcgi_cache fastcgicache;
          fastcgi_cache_valid 200 60m;
          fastcgi_cache_bypass $no_cache;
          fastcgi_no_cache $no_cache;
          fastcgi_ignore_headers Cache-Control Expires Set-Cookie; # Игнорируем заголовки, относящиеся к кешированию, полученные от FastCGI-сервера

          try_files $uri =404;
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          fastcgi_pass php8-fpm;
          fastcgi_index index.php;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_param PATH_INFO $fastcgi_script_name;
    }
 
	location / {
          try_files $uri $uri/ /index.php?$query_string;
	}

	location /karman {
        set $no_cache 1;
    }
}