Hyperz Documentation > Knowledgebase > NodeJS Websites > Adding More Websites

Adding More Websites


This guide extends the documentation for Step 1.

Note: This guide will not work for all EJS Based websites, this is designed to work with the basics.

Step 1

Adding a new website to NGINX is actually very easy, first, create your server block(s).

server {
  server_name example.com; # Change domain to yours.
  location / {
    proxy_pass http://localhost:3000; # Change the port if changed in the config file.
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header X-Real-IP $remote_addr;

Make sure to alter the example.com and the 3000 to meet your desired domain and port.

Once you have done so, navigate to your NGINX default file (/etc/nginx/sites-available/default) and open it.

Simply scroll to the very bottom of your NGINX default file, and paste in the above server block.

Now, open up your desired SSH program, for me I prefer Termius.
And run this command to restart your NGINX service: sudo systemctl restart nginx

If the restart fails, check out this guide to find out why.

Step 2

Now it is time to create an SSL cert so our website can be secure! This is very easy to do as we have already installed Certbot!

Simply run this command in your terminal: sudo certbot --nginx -d example.com after replacing example.com with the domain you intend to create the certificate for.

Make sure you have pointed your domain to your VPS with a DNS A record already!

If it asks you for a redirect option, press 2.

Step 3

Navigate to your domain, and if it reads you a 502 error, that means that your domain has been properly connected to your server! All you have to do now is start your website!

Was this article helpful?

25 out of 44 found this helpful