# Example server block — adjust paths, php-fpm socket, and SSL for your host.
# Include anifan-rate-limit-zones.conf in http { } first.

server {
    listen 443 ssl http2;
    server_name anifan.az www.anifan.az;
    root /home/anifanaz/public_html/anifan_website/public;
    index index.php;

    location / {
        limit_req zone=anifan_general burst=40 nodelay;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ ^/api/auth/register$ {
        limit_req zone=anifan_auth_register burst=1 nodelay;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ ^/api/auth/login$ {
        limit_req zone=anifan_auth_login burst=3 nodelay;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ /email/resend$ {
        limit_req zone=anifan_email_resend burst=2 nodelay;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ^~ /api/ {
        limit_req zone=anifan_api burst=20 nodelay;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    }
}
