Nginx + reactjs + react router

Hello,
I’m new to Hestiacp, I’m asking a lot of questions, as I install my applications I have doubts.
I’m installing reactjs + react router (route management), in my localhost I have an nginx with this content and it works perfectly.

server {
    client_max_body_size 100M;
    listen 80;
    index index.html;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www/html;

    location / {
        try_files $uri $uri/ /index.html;
        gzip_static on;
    }
}

I try to replicate it in Hestiacp but I don’t have a template, so I make a copy of default.tpl and stpl to create a new template to use reactjs, the problem is that it is not working as it should.
This is the content of my new template react.tpl/stpl

server {
    listen      %ip%:%web_port%;
    server_name %domain_idn% %alias_idn%;
    root        %docroot%;
    index       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.html;
    }

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

    location ~* "/\.(htaccess|htpasswd)$" {
        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_*;
}

I leave a video recording to see the error.

Link to video

Any idea why that might be?

Creating a template is already a good idea, the 404 just means file not found, probaly you’ll find further informations in your log files, for example the path he tries to reach. Docs about template handling is here: https://docs.hestiacp.com/admin_docs/server_management.html#how-do-web-templates-work

1 Like

After many days, I reinstall everthing.
now I can get reactjs with react router