server {
    listen 80;
    listen [::]:80;
    server_name  DOMAIN;
	
	index index.php index.html;
	
	root PROJECT_FOLDER;
	
	access_log /var/log/nginx/DOMAIN-access.log;
	error_log /var/log/nginx/DOMAIN-error.log;
	
	location ~* \/\.ht {
		deny all;
	}	
	
	location ~* (\.tpl|.twig|\.ini|\.log|(?<!robots)\.txt) {
		deny all;
	}
	
	location ~* \/\.git {
		deny all;
	}
	
	location ~* \/image.+(\.php) {
		deny all;
	}
	
	location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
		expires max;
		log_not_found off;
	}
	
	location = /sitemap.xml {
		rewrite ^(.*)$ /index.php?route=extension/feed/google_sitemap last;
	}

	location = /googlebase.xml {
	    rewrite ^(.*)$ /index.php?route=extension/feed/google_base last;
	}

	location /system {
	    rewrite ^/system/storage/(.*) /index.php?route=error/not_found last;
	}
	
	location = /favicon.ico {
		log_not_found off;
		access_log off;
	}

	location = /robots.txt {
		allow all;
		log_not_found off;
		access_log off;
	}
	
	location /admin { index index.php; }

	location / {
		try_files $uri @opencart;
	}
	
	location @opencart { 
		rewrite ^/(.+)$ /index.php?_route_=$1 last; 
	}
	
	location ~ \.php$ {
		try_files $uri =404; 
		
		fastcgi_pass   unix:/run/php/php8.0-fpm.sock;
		fastcgi_buffers 16 16k;
		fastcgi_buffer_size 32k;
		fastcgi_index  index.php;
		
		include fastcgi_params;
		fastcgi_param       SCRIPT_FILENAME  $document_root$fastcgi_script_name;
	}
}

