Web Hosting - Create and Manage Node.js Applications
Overview of how your NodeJS application will work with your DoIT Web Hosting Account.
Disclaimer
Please take a minute to read this entire document to help determine your needs. Some configuration for your application requires assistance from DoIT Web Hosting and we would like to avoid multiple support requests where possible. In addition to your NodeJS needs, also mention if your site needs support for NetID login, or Manifest.
General Overview
DoIT Web Hosting uses Plesk, which is web hosting automation software to manage your site.
Plesk typically uses Apache to serve requests in a classic LAMP environment. However, Apache does not support NodeJS and Plesk relies on Phusion Passenger, another web server that supports NodeJS that forwards requests to Phusion Passenger for processing.
Getting Started
When clicking on the NodeJS icon from your Plesk dashboard you should see something similar to the following when you have a fully configured site:
For NodeJS applications that are developed locally, it's common to run various terminal commands via NPM to install & update dependencies. This process is a little different when running your application with Plesk. While you can access a web terminal from the Plesk dashboard named "SSH Terminal", each account's terminal session is chrooted or has severely limited access to the relevant terminal commands you would need to install dependencies for your application. The preferred way to install dependencies is to configure your "Application Root" to point to the folder that has your package.json. Then click the "NPM Install" button.
To run your application, you will also need to locate an "Application Startup File" and by default is set to app.js. This is typically the file that starts the application or your Express server.
A word about the "Document Root". By default the Document Root of the site is /httpdocs. This can be changed to something like /httpdocs/myapp should you need that. Know that you cannot change the Document Root without making a request to DoIT Web Hosting.
The "Run Script" button from the UI will run any scripts you have found in your package.json.
Proxying Requests (Single Page Web Apps)
When you run your NodeJS application with Express, additional configuration may be needed to proxy requests to your Express application. Something similar to the following:
<Location /api>
ProxyPass http://localhost:3000
ProxyPassReverse http://localhost:3000
</Location>
A request will need to be made to DoIT Web Hosting as access to your Apache configuration is restricted.
Debugging Issues
Phusion passenger uses the system to log errors and not your accounts user logs, so to display relevant error messages you need to change your "Application Mode" to "Development". Then you will see any error messages from your NodeJS application on your web browser. Obviously, on your production server you will not want to run the application in "Development" mode and should use "Production".
DoIT Web Hosting will assist with configuration issues with the hosting platform, but will not edit code, NPM install, or make your application “Work” as we do not have dedicated staff to address these issues. If you are unable to get your application working and need help, there are resources available on campus should you need assistance.
-
Request web development service from DoIT (https://it.wisc.edu/request-web-service-doit/)
Other Resources
I suggest you review some of the Demo applications below to get setup with how your application will function, before you upload your application to your site. Once you have a good idea of how your application will function, you can make similar changes to your application locally (namely folder structure) to ensure a working application with Plesk.
Basic upload and activation of NodeJS application (Video) (https://www.youtube.com/watch?v=4K-WJ2c54Ag&t=252s)
NodeJS Hello World Application from Plesk (https://github.com/plesk/node-hello-world)
Express based demo application from Plesk (https://github.com/plesk/node-express)
Plesk NodeJS Support Documentation (https://docs.plesk.com/en-US/obsidian/administrator-guide/website-management/nodejs-support.76652/)
Account Limitations
-
Any individual domain hosted by Web Hosting can support one of PHP, Ruby, or NodeJS language. If support for two or more of the scripting languages is required, additional domains must be used. (Example: domain.wisc.edu for the frontend/PHP and apps.domain.wisc.edu for the backend/Node.js.)
-
Shibboleth attributes can only be accessed via headers, they will not be available within the system environment.