Unable to create a template to run grav CMS on subfolder

First of all, thanks for this awesome open-source control panel — it’s truly the best option among all others! :wink:
I’m facing an issue while trying to create a custom template.

When I installed Hestia, I didn’t choose the option to install Apache + Nginx — I selected only Nginx (unchecked Apache) because I thought it would be one server or the other.

Now, if possible, I would like to keep it that way without having to reinstall everything.

I downloaded and installed Grav CMS (flat-file) in the /root (public) directory, and it worked fine.
However, when I place a static site in the root and create a subfolder /grav (with the CMS inside it), I’m unable to access it, because it needs to be redirected properly using a template (since I’m using only Nginx).

ChatGPT taught me that the .htaccess file is missing in pure Nginx setups, so I would need to create a custom template — and I tried to do that.

I created gsubfolder.tpl and gsubfolder.stpl inside /usr/local/hestia/data/templates/web/nginx/, but they never show up in the Hestia panel template options. I run
sudo systemctl reload nginx
sudo systemctl restart nginx
systemctl restart hestia
v-rebuild-web-domain Admin2 painel3.domainchanged.com
Even rebuild the site using control panel from Hestia. But give me some “error”

What am I doing wrong?

My manually optimized sites usually achieve 98–100 on PageSpeed Insights, and I’m worried that reinstalling the server would cause me to lose performance.

Inside my gsubfolder.stpl, I have: `
#=========================================================================#

GRAV TEMPLATE

Based on Default Template

Web Templates and FastCGI/Proxy Cache | Hestia Control Panel

#=========================================================================#

server {
listen %ip%:%proxy_port%;
server_name %domain_idn% %alias_idn%;
error_log /var/log/%web_system%/domains/%domain%.error.log error;

    include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;

    location ~ /\.(?!well-known\/|file) {
            deny all;
            return 404;
    }

    location /grav/ {
            root       %docroot%;
            index      index.php index.html index.htm;
            try_files  $uri $uri/ /grav/index.php?$args;

            location ~ \.php$ {
                    fastcgi_pass   127.0.0.1:9000;
                    fastcgi_index  index.php;
                    include        fastcgi_params;
                    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    fastcgi_param  SCRIPT_NAME $fastcgi_script_name;
            }
    }

    location /error/ {
            alias %home%/%user%/web/%domain%/document_errors/;
    }

    include %home%/%user%/conf/web/%domain%/nginx.conf_*;

}
`

If you are using only Nginx, you should place the templates in dir /usr/local/hestia/data/templates/web/nginx/php-fpm/

You must also replace %proxy_port% with %web_port% and %proxy_ssl_port% with %web_ssl_port% in your templates.

Anyway, if you want to use a base template, check grav.tpl and grav.stpl inside the template dir /usr/local/hestia/data/templates/web/nginx/php-fpm/

Once done, edit your domain, select the new template and save.

Fist step is to fix the error in hestia.conf

Go to /usr/local/hestia/conf/hestia.conf

And check the contents in there

It look like 'POLICY_CSRF_STRICTNESS' has some wrong quotes

You need to create a template in:
/usr/local/hestia/data/templates/web/nginx/php-fpm/

But I am sure we allready have a temple for grav…

Also we don’t run php on port 9000 any more

Check out the current grad template :slight_smile:

I was putting the templates in the wrong place (/nginx) though should be /nginx/php-fpm.

I tried use grav template, but once Grav CMS is inside /grav folder, maybe the template don’t see the CMS.

I made a mess earlier with POLICY_CSRF_STRICTNESS, but now it’s correct. Thanks!

I selected the Grav template in the options, and it works fine when Grav CMS is installed in the root / (home) directory.
However, when it’s placed inside a subfolder /grav, the page returns a 404 error.
This doc from grav talk about that.

ISPConfig charges 5 euros for a 600-page documentation. Maybe you guys could create a parallel documentation that explains things better for noobs like me — it could even become a source of income for the project, maybe?

Do you personally use Apache + Nginx + php-fpm. I think if using like that I could directly edit .htaccess inside root sites, it is less headache.