Setting up a reverse proxy server

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:

  1. 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;
}
  1. 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
  1. If everything is fine, then you should see this:

  1. 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:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset