Follow my below steps and you would be good.
In your spring boot application under application/properties do not define any port so your sprig boot can run by default to 8080 or 9080 is fine if you are ok to run on it.
Create fat jar of your spring boot project
deploy it to /opt/your project name on server.
run you boot app with nohup java -jar jarname & or you create service for it read spring documentation to run your jar as service.
it will start your app on 8090 or 8080 whatever you want.
Now lets come to your front end app which is in react.
to order to run your front end app there are couple of ways.
- install apache or ngnix server on your machine
- run yarn build which will generate your optimized files under build folder, make sure you define your app backend url.
- deploy all generated files under
apache/ngnix root folder for ex /var/www/html
Now if you have lets say domain name example.com then your front end app can be accessible with http://www.example.com and backend apis are available at http://www.example.com:8080 make sure 8080 and 80 are allowed.
Now you think,no i want to also want my apis to be accessible by www.example.com then first make sure there context path is defined your apis so they available with base path lets say /api is your base path.
then define proxy in apache or ngnix server.
<VirtualHost *:80>
ProxyRequests Off
ProxyPass /api http://localhost:8080/api
ProxyPassReverse /api http://localhost:8080/api
</VirtualHost>
Now you are good to also access your apis at www.example.com/api