'Setup two React websites on the same domain with NGINX, deployed to separate folders

I am trying to configure NGINX to serve two separate websites on the same domain, with one of the websites being served at the top level of the domain, and the other accessible from domain.com/gol

The first websites files are on the server located at /var/www/morderindustries.com/public

The second websites files are on the server located at /var/www/morderindustries.com/gol

This is my nginx config for the website:

server {
  listen 443 ssl default_server;
  listen [::]:443 ssl default_server;
  ssl on;
  ssl_certificate /etc/ssl/ssl-bundle.crt;
  ssl_certificate_key /etc/nginx/ssl-certs/www.morrder.com.key;
  server_name  morrder.com www.morrder.com;
  # index index.html


  error_log  /var/log/nginx/morderindustries.com.error.log;
  access_log  /var/log/nginx/morderindustries.com.access.log;

  location / {
      root /var/www/morderindustries.com/public;
      try_files $uri $uri/ /index.html =404;
  }

  location /gol {
      root /var/www/morderindustries.com/gol;
      try_files $uri $uri/ /index.html =404;
  }
  
  error_page  404 /404.html;

  # redirect server error pages to the static page /50x.html
  error_page   500 502 503 504  /50x.html;
  location = /50x.html {
      root   /var/www/morderindustries.com/public;
  }
}

With this setup, https://morrder.com works fine and serves the website that is located in the /public folder.

I expect https://morrder.com/gol to serve the second website in the /gol folder, but the result is the following:

enter image description here

Does anyone have a clue as to what I've screwed up?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source