DEV Community

Cover image for Add HestiaCP statistics with Nextjs or Nodejs application! (domain.tld/vstats)
Nurul Islam Rimon
Nurul Islam Rimon

Posted on

Add HestiaCP statistics with Nextjs or Nodejs application! (domain.tld/vstats)

Do you want to add statistics route with your MERN applications?

  • If you didn't setup Hestiacp then Click here to see installation instructions.

If you already deployed the app with HestiaCP. Now open your domain to setup statistics.

Follow the instruction below:

  1. Login to the panel. visit: your-ip:8083
  2. Visit "Web" menu and choose your domain.
  3. Click on the "Edit Domain" icon.

Image description

  1. Now click on "Web Statistics" option and select "awstats".
  2. Now Save this.

It will take a while to setup.
If your application handles unknown routes automatically the you should update configuration of the Nginx.

  1. Login into the hosting server using ssl as described in this article
  2. Go to the Nginx configuration file using command like:
 cd /home/bdcommerce/conf/web/demo.bdcommerce.app
Enter fullscreen mode Exit fullscreen mode
  1. Now edit nginx.conf file in nano editor. Command:
nano nginx.conf
Enter fullscreen mode Exit fullscreen mode

Note: If it's immutable unmute it. Command:

chattr -i nginx.conf
Enter fullscreen mode Exit fullscreen mode
  1. Add /vstats route between location ~ /.(?!well-known\/|file) { & location / {

Code:

location /vstats {
        alias /home/demo.bdcommerce.app/web/demo.bdcommerce.app/stats;
        index index.html;
    }
Enter fullscreen mode Exit fullscreen mode

It will be positioned like the SS below:

Image description

  1. Do the same job for nginx.ssl.conf (Repeat Point 3 & 4 at the stage)

  2. Now restart the nginx server:

sudo systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode
  1. Visit your statistics route to see the statistics like: https://your-domain/vstats

Note: If it works then don't forget to make config file immutable.

Thanks,
N I Rimon

Top comments (0)