Meteor Directly Deploy with "Node main.js" (Generic VPS deploy )

I want to deploy my app on Ubuntu 20 and then running forever on pm2
But first how do i make the app running ?

MONGO_URL=mongodb://localhost:27017/myapp ROOT_URL=http://localhost:3000 node main.js

I tried the above script and the server (backend) is running ok. However, i don’t see the frontend thing .
I failed to curl http://localhost:3000 .

If i try this script MONGO_URL=mongodb://localhost:27017/myapp ROOT_URL=http://my-app.com node main.js

I could acess the app through http://my-app.com, But i don’t know how to apply the nginx setting.

How to deploy the meteor plain node app
And modify the basic nginx config to increase the worker_connection for multi-core CPU.

I don’t know how to config the nginx and i tried something like below

`
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
worker_connections 10240;
multi_accept on;
}
http {
# websockets upgrade mapping
map $http_upgrade $connection_upgrade {
default upgrade;
‘’ close;
}

# load balance 4 instances of a node process
upstream my-app.com {
    server 127.0.0.1:3000;
    server 127.0.0.1:3001;
    server 127.0.0.1:3002;
    server 127.0.0.1:3003;
}

# server endpoint configuration
server {
    listen                  80;
    server_name             my-app.com;
}

server {
    listen                  443 ssl;
    keepalive_timeout       5m;

    # SSL configuration
    server_name             my-app.com;


    location / {
        # websockets configuration, using our mapping
        proxy_pass          http://my-app.com;
        proxy_http_version  1.1;
        proxy_set_header    Upgrade $http_upgrade;
        proxy_set_header    Connection $connection_upgrade;
    }
}

}`

Change your location / to this and it should work:

location / {
    proxy_pass http://localhost:3000;
    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;
  }
1 Like

Thank you for the response!

Idk why it worked for the localhost:3000
But still something’s wrong,And the dynamic import is fetching from wrong address

It should be the address i put on the browser http://my-app.com instead of localhost:3000

Can you tell me how you deploy your app ? ( Forget it if you’re using Galaxy or aws)

I use this: https://github.com/bordalix/yamup
I use it everyday, it just works.
I have all my projects on AWS EC2. You can have multiple meteor projects on the same EC2 instance, just give them different ports e configure your nginx.

Thank you agin !
And i have fixed the problem i think. Now my app is running on pm2 with 8 process without problem.