I'm trying to create a ReactJS app on a remote Ubuntu server. In order to test it in the browser I'm using the NGinx reverse-proxy features as this.
server {
listen 80;
server_name mentalg.com;
location / {
proxy_pass http://172.31.23.249:5000;
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;
}
location /client/ {
proxy_pass http://172.31.23.249: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;
}
}
the 5000 port is for the REST /api
end-points, all good here.
But the 3000 port on which the development react server runs creates issues.
The site opens as needed at http://mentalg.com/client
, but inside the index.html
there is a url for the script file to be executed as
static/js/bundle.js
file. This file is served by the React dev server normally but NGinx won't see it.
The url static/js/bundle.js
is generated on the fly by the create-react-app
dev server, can't control it.
How do I modify further the nginx proxy to server the files from static
folder correctly?