Web Tier

  1. Install unzip and unzip code from file frontend.zip

EC2 EC2

  1. Same as Application Tier, we also create a directory and user for the frontend project

EC2 EC2

  1. Change the backend url to the ip of Application tier EC2

EC2 EC2

  1. Install node, npm

  2. Install nginx

EC2 EC2

  1. Build the project, after the build is completed, a folder named build will be created
npm run build

EC2

  1. Use nginx as a web server: create an nginx file named react.conf at the path /etc/nginx/conf.d/. Add content (like photos). Then restart nginx

EC2 EC2 EC2

  1. Use nginx to revert the proxy: create a file named react_nginx at the path **/etc/nginx/sites-enabled/ with the content:

EC2

  1. Open additional HTTP port 80 of Security Group - Public subnet

EC2

  1. nginx will forward requests from port 80 to port 3000 running the project, now access the project using the EC2 Public ip

EC2

  1. Error 500. This error occurs because we have not granted permission to another user to access the build folder. We just need to check which user nginx is, here it is www-data, then add it to the group frontend

EC2 EC2

  1. Done, our website is already working via EC2’s IP port 80.

EC2