cd /home/<YOUR REACT APP> to go to your react folderyarn build to build a deployment version. now you can serve the whole thing as htmlsudo ln -s ~/<YOUR REACT APP> /var/www/<YOUR REACT APP> to symlink your files to /var/www because nginx will only serve files from there. symlink === make shortcutsudo chmod -R 755 /var/www to grant permissionssudo nano /etc/nginx/sites-available/react to open a react settings files for nginxserver {
listen 80;
root /var/www/<YOUR REACT APP>/build;
index index.html index.htm index.nginx-debian.html;
server_name <YOUR ECS INSTANCE'S PUBLIC IP ADDRESS>;
location / {
try_files $uri /index.html;
}
}this will tell nginx to serve your index.html files that live in /var/www/<YOUR REACT APP>/build to the <YOUR ECS INSTANCE'S PUBLIC IP ADDRESS> endpoint. replace the ECS instance's IP Address with your domain name if you have one.
sudo ln -s /etc/nginx/sites-available/react /etc/nginx/sites-enabled/reactservice restart nginx or sudo systemctl restart nginx. it it doesn't do that, perhaps it wasn't started at all. so `service start nginx nginx commandsls). repair it with this.use the nano