How to configure Nginx for calls error_page 404 on a hosted domain

I am using two different PHP scripts first Grav and second Flarum on a domain and I wish to show common error pages in both the software, for this I tried by entering

error_page 404 /404.html;

in my Default Web Domain Template, I am including my configuration

server {
listen %ip%:%web_port%;
server_name %domain_idn% %alias_idn%;
root %docroot%;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/%domain%.log combined;
access_log /var/log/nginx/domains/%domain%.bytes bytes;
error_log /var/log/nginx/domains/%domain%.error.log error;
include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;
location / {
try_files $uri $uri/ /index.php?$query_string;
location ~* ^.+.(jpeg|jpg|png|webp|gif|bmp|ico|svg|css|js)$ {
expires max;
fastcgi_hide_header “Set-Cookie”;
}
location ~ [^/].php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass %backend_lsnr%;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
#ERROR-PAGE-START Error page configuration, allowed to be commented, deleted or modified
error_page 404 404.html;
#This rule help to read the index.php file in Flarum root folder
location /community/ {
try_files $uri $uri/ /community/index.php?$query_string;
}
location ~* ^/community/(.).php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass %backend_lsnr%;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param HTTP_PROXY “”; # Fix for https://httpoxy.org/ vulnerability
fastcgi_index index.php;
}
location ~
^/community/(.).html$ {
expires -1;
}
location ~
^/community/(.).(css|js|gif|jpe?g|png)$ {
expires 1M;
add_header Pragma public;
add_header Cache-Control “public, must-revalidate, proxy-revalidate”;
}
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types application/atom+xml
application/javascript
application/json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
text/css
#text/html – text/html is gzipped by default by nginx
text/plain
text/xml;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6].(?!.SV1)";
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location ~
/(.git|cache|bin|logs|backup|tests)/.
$ { return 403; }
location ~* /(system|vendor)/..(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
location ~
/user/..(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
location ~ /(LICENSE.txt|composer.lock|composer.json|nginx.conf|web.config|htaccess.txt|.htaccess) { return 403; }
location ~ /.(?!well-known/) {
deny all;
return 404;
}
location /vstats/ {
alias %home%/%user%/web/%domain%/stats/;
include %home%/%user%/web/%domain%/stats/auth.conf
;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include %home%/%user%/conf/web/%domain%/nginx.conf_*;
}

So, any clue or suggestion where I am wrong?