NodeJS App and VSTAT folder

Hi. I make new template to hide my nodejs app by nginx reverse poxy. This is a config. With this config I have no issue with nodejs, everything is working well.

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

	ssl_certificate     %ssl_pem%;
	ssl_certificate_key %ssl_key%;
	ssl_stapling        on;
	ssl_stapling_verify on;

	# TLS 1.3 0-RTT anti-replay
	if ($anti_replay = 307) { return 307 https://$host$request_uri; }
	if ($anti_replay = 425) { return 425; }

    gzip on;
    gzip_min_length  1100;
    gzip_buffers  4 32k;
    gzip_types    image/svg+xml svg svgz text/plain application/x-javascript text/xml text/css;
    gzip_vary on;

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

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

	location / {
		proxy_pass http://127.0.0.1:3000;

        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_set_header X-NginX-Proxy true;
        proxy_cache_bypass $http_upgrade;

		location ~* ^.+\.(%proxy_extensions%)$ {
			try_files  $uri @fallback;

			root       %sdocroot%;
			access_log /var/log/%web_system%/domains/%domain%.log combined;
			access_log /var/log/%web_system%/domains/%domain%.bytes bytes;

			expires    max;
		}
	}

	location /stats/ {
		alias %home%/%user%/web/%domain%/stats
	}

	location @fallback {
		proxy_pass https://%ip%:%web_ssl_port%;
	}

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

	proxy_hide_header Upgrade;

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

But now https://%domain%/vstat folder become unavailable. How to enable this folder or exclude from redirecting request to nodejs app?

1 Like

You are trying to access location /vstat (usually it is /vstats/) but you didn’t define a location por that path, you are using location /stats/ instead.

Change this:

location /stats/ {
		alias %home%/%user%/web/%domain%/stats
	}

To this:

location /vstats/ {
		alias %home%/%user%/web/%domain%/stats
	}

Rebuild your site and try to access to https://%domain%/vstats/

When I put you settings I get from hestia panel error Error: nginx restart failed
I think this come to conflict with hestia default settings for stat folder.

location /vstats/ {
		alias %home%/%user%/web/%domain%/stats
	}

So, you modify the template replacing /stats/ with /vstats/ and when you try to modify your site to use that template then you get the nginx error?

What is the output of nginx -t when you see the error?

If you don’t replace /stats/ and you try to access https://yourdomain/stats/ do you get any error?

Ups, that is wrong, I copied it from your example and there isn’t a trailing slash and also the semicolon.

Use this:

location /vstats/ {
		alias %home%/%user%/web/%domain%/stats/;
	}
1 Like

Yep. Thanks. Now its work.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.