server {
	listen 443 ssl;
	listen [::]:443 ssl ipv6only=on;

	server_name domain.zone;

	root /var/www/huesos/mirzaev/huesos/system/public;

	index index.php;

	ssl_certificate /etc/letsencrypt/live/domain.zone/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/domain.zone/privkey.pem;
	include /etc/letsencrypt/options-ssl-nginx.conf;
	ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

	location / {
		try_files $uri $uri/ /index.php;
	}

	location /api/cdek {
		rewrite ^/api/cdek(.*)$ /$1 break;
		index cdek.php;
	}

	location ~ /(?<type>categories|products) {
		root /var/www/arming_bot/mirzaev/arming_bot/system/storage;
		try_files $uri =404;
	}

	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
		fastcgi_pass unix:/run/php/php8.4-fpm.sock;
	}
}

server {
	listen 80 default_server;
	listen [::]:80 default_server;

	server_name domain.zone;

	if ($host = domain.zone) {
		return 301 https://$host$request_uri;
	}

	return 404;
}

