Deploy Frontity on NGINX Server

Hi, i saw the guide on how to deply on Now, but what should i do if i have to deploy on port 3001 on NGINX in a VPS?

Thanks

Frontity is a regular Node app, so you can follow any guide written for Node, like this one:

If you just start the server using npm run serve, it won’t restart if it crashes, or when the server reboots. For that reason, we recommend you to use either forever or pm2.

The alternative to npm run serve when using a node file is:

node node_modules/frontity/dist/commands.js serve --port 3001

Forever

So you can start forever using:

forever start node_modules/frontity/dist/commands.js serve --port 3001

pm2 (alternative)

With pm2 that is:

pm2 start node_modules/frontity/dist/commands.js -- serve --port 3001

or using npm to run a npm script:

pm2 start npm --name "frontity" -- run serve -- --port 3001

You can test both forever or pm2 in your machine first.

Nginx

For Nginx, nothing fancy either. Any copy-paste configuration of a Node configuration for Nginx should work fine:

server {
    listen 80;
    server_name yoursitename.com;

    location / {
        root /home/nodeuser/app   
        proxy_pass http://127.0.0.1:3001;
        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;
    }
}

EDIT: Sorry, I forgot to add port 3001

3 Likes