mongodbvpsmernwebminvirtualmin

How do I set my VPS Webmin/Virtualmin server to show data from MongoDB in the hosted website?


This is my first question I hope I do it right. So :

I developed a MERN website, on which I have perfect connection with a MongoDB db as well as an Amazon S3 one.

I am currently trying to host it on a Hostinger VPS with Virtualmin and Webmin. The data is in thanks to FTP working, so the website design shows but the mongoDB data is missing.

So far :

So my question is : what are the following steps to make the way to data, through the server, to the website ?

I'm new to this and I've searched for several days now everywhere without any success, and the hosting support is lost on the matter...

Thanks!


Solution

  • In case it helps anyone I did succeed in setting up the server, it's quite a bit of work. Here's my config :

    server {
      listen  80;
      listen 443 ssl;
    
      root /the/frontend/root/folder;
      server_name _;
      
      ssl on;
      ssl_certificate /the/ssl/.crt/file;
      ssl_certificate_key /the/ssl/.key/file;
    
      # react app & front-end files
      location / {
        try_files $uri /index.html;
      }
    
      # node api reverse proxy
      location /api/ {
        proxy_pass http://localhost:portlistenedbybackend/api/;
      }
    }
    

    At first I discarded Webmin and Virtualmin since all I could find (from support included) was tutorials to setup the server via console. So bits by bits I set it up. Then, finally, I got from the support a tuto to setup the server from Webmin. But to this day I can't say wether that made a difference in the structure. But at least it's clean.

    systemctl status theserviceyouwanttosee

    systemctl start theserviceyouwanttostart

    systemctl stop theserviceyouwanttostop

    systemctl restart theserviceyouwanttorestart

    Examples of services : nginx, mongod...

    Test if Nginx is setup properly : sudo nginx -t

    reload nginx config file after any modification : sudo nginx -s reload

    See the last errors logged by nginx : sudo tail -f /var/log/nginx/error.log

    Save current pm2 settings : pm2 save

    Backend execution logs : sudo pm2 logs

    Identify the processes still running with mongo (useful if mongod won't restart properly) : pgrep mongo

    Kill the mongo process to be able to start fresh : kill <process>

    Show all services used by server : sudo systemctl

    See all processes in execution and stats of the CPU amongst other things : top

    I'm still new to all of this despite my couple of weeks on the subject so this description is most probably improvable. don't hesitate to suggest any improvement, mistake, or ask questions, I'll do my best to answer them.

    Cheers!