How to run more than one app on one instance of EC2

后端 未结 2 1082
陌清茗
陌清茗 2021-01-30 18:46

I have a couple of small production sites and a bunch of fun hobbyist/experimental apps and such. I\'d like to run all of them on one EC2 instance.

Can I install node.js

2条回答
  •  醉酒成梦
    2021-01-30 19:02

    Already answered @ https://stackoverflow.com/a/50528580/3477353 but mentioning it again.

    Adding to the @Daniel answer, I would like to mention the configuration of my nginx for those who are looking for the exact syntax in implementing it.

    server {
      listen 80;
      server_name mysite.com;
      location / {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  Host       $http_host;
        proxy_pass        http://127.0.0.1:3000;
      }
    }
    server {
      listen 80;
      server_name api.mysite.com;
      location / {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  Host       $http_host;
        proxy_pass        http://127.0.0.1:4500;
      }
    }
    

    Just create two server objects with unique server name and the port address.

    Mind proxy_pass in each object.

    Thank you.

提交回复
热议问题