I've done this tutorial,
https://reactjs.org/tutorial/tutorial.html
Then uploaded it to production server, running on ubuntu nginx with SSL. Ran npm run build
, created the build files and served static files with serve module serve -s -p 8083 build
. It runs OK on port 8083.
But when I try to add it as a pm2 service pm2 serve ./build/ 8083
I get a 404 not found (when it's not running the error is 502 Bad Gateway)
I tried several ways, with pm2 serve ./ 8083
, pm2 serve ./public/ 8083
, etc.
Nginx config:
location ~* /.(js|jpg|png|css)$ {
access_log off;
expires max;
}
location = /react-game {
root /var/www/test.com/html/react-game/build;
proxy_pass http://localhost:8083;
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;
autoindex off;
}
Any ideas how to replicate serve -s -p 8083 build
with pm2?
Thanks!