we will start preparing our vpc by picture by picture : when ever you enter into google cloud console , you will see some thing like , we called it sandbox :
after filling this vpc form , it will take some time , if everything ok , then you have a vpc for you .
filled the form like avobe picture , but you can change as your needs.
with inside it , you need a router for your nat , add it as picture describes.
we showed how to filled it . the main difference of it with pubic ip ones is
External ip : Network subnet tab
clone this project git clone address
cd backend-deploy-in-vpc-with-load-balance
go to : https://github.com/nodesource/distributions , take binary 16 version and install
node --version
sudo corepack enable
will enable yarn and other npm related corepack.yarn add nodemon
yarn run dev
sudo apt update
sudo apt install default-mysql-server
sudo systemctl start mysql
sudo systemctl enable mysql
sudo mysql_secure_installation
mysql -u root -p
sudo mysqld_safe --skip-grant-tables &
mysql -u root
sudo systemctl stop mysql
sudo systemctl start mysql
sudo apt install redis
redis-cli --version
we create a public ip available vm instance template so that we can make a load balance cloing the publically setted template.
cd /etc/nginx
ls
sudo nano nginx.conf
change this conf file as needed :
`events { # empty placeholder }
http {
server {
listen 80;
location / {
proxy_pass http:https://frontend-raihan;
}
location /api/ {
rewrite ^/api/(.*)$ /$1 break;
proxy_pass http:https://backend-raihan;
}
}
upstream frontend-raihan {
server 11.10.10.12:80;
server 13.10.10.14:80;
}
upstream backend-raihan {
server 10.10.0.5:8000;
server 11.10.10.6:8080;
}
}`
location /api/ { rewrite ^/api/(.*)$ /$1 break; proxy_pass http:https://backend-raihan; }
upstream backend-raihan { server 10.10.0.5:8000; server 11.10.10.6:8080; }
set two backend there so that whenever you have huge request it will auto transfer user to other one.
sudo nginx -s reload