I have created a web app starting with the command npx create-react-app myapp
. I am hoping to use Phusion Passenger with Nginx to serve the app from its own subdomain. My problem (I believe) is telling Phusion Passenger where to find the file that Node.js needs to launch.
Everything is working fine on my development machine.
I have used git push ...
to upload the project to my Ubuntu 16.04 server. There, as described here, I have run npm run build
.
According to the documentation this...
- Builds the app for production to the build folder.
- Correctly bundles React in production mode and optimizes the build for the best performance.
- Ensures that the build is minified and the filenames include the hashes.
In short: Your app is ready to be deployed.
I've successfully used serve -s build
to launch the app on port 5000, and have checked using curl http://localhost:5000
that a minified HTML file is served locally on the server.
Now I need to tell Phusion Passenger to launch the app, and this is where I need help. Following the instructions here, I've created the following nginx config file:
server {
listen 80;
server_name subdomain.example.com;
# Tell Nginx and Passenger where your app's 'public' directory is
root /var/www/myapp/web/public;
# Turn on Passenger
passenger_enabled on;
# Tell Passenger that your app is a Node.js app
passenger_app_type node;
passenger_startup_file app.js; ## THIS IS WHERE I THINK THE ISSUE IS ##
}
My understanding is that the last line must indicate which file Node.js should be launching. In the case of a project create using npx create-react-app...
, the file launched by Node.js in development mode is at src/index.js
, and not app.js
.
Where should I tell passenger_startup_file
to find the file to run in production mode?
Or should I be thinking about this in a completely different way?