###### tags: `EC2`
# Let both front and back run on the same machine(EC2)
- Front: 3000
- Back: 5000
The front-end will call the back-end using API, so we have to let nginx proxy the request to the back-end.
First, set up package.json to serve the port which back-end will use.
```
"proxy": "https://www.shankera.tk:5000"
```
At the same time, we need to set up nginx to proxy the request to the back-end. The url sta
rt with /api will be proxy to the back-end (port 5000).
```conf
#test.conf
server {
# 把 request 轉給 localhost 的 3000 port
location / {
proxy_pass http://127.0.0.1:3000;
#client_max_body_size 100M;
}
location /api {
proxy_pass http://localhost:5000;
}
}
```
# Running "npm start" with PM2.
1. Installing PM2: Make sure you have installed PM2 globally on your machine with this command:
```bash
npm install pm2 --location=global
```
2. Start npm: PM2 also supports to run npm start:
```bash
pm2 start npm -- start
```
     Use the --name option to assign a name to the PM2 process.
```bash
pm2 start npm --name "my_app" -- start
```
3. List all service running with pm2:
```bash
pm2 list
```