As I mentioned previously, we need to set up a reverse proxy server to send the traffic from port 80 (HTTP) to port 3000 (React app). To do this, you need to open the following file:
sudo vi /etc/nginx/sites-available/default
The steps are as follows:
- In the location / block, you need to replace the code in the file with the following:
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
- Once you have saved the file, you can verify whether there is a syntax error in the nginx configuration with the following command:
sudo nginx -t
- If everything is fine, then you should see this:
- Finally, you need to restart the nginx server:
sudo systemctl restart nginx
Now, you should be able to access the React application without the port, as shown in the following screenshot: