A minimalist NodeJS application that serves static HTML and CSS files.
-
Install dependencies:
npm install -
Start the server:
npm start -
Open your browser and navigate to:
http://localhost:3000
server.js- Express server configurationpublic/index.html- HTML file served by the applicationpublic/main.css- CSS styles for the HTML file
This repository includes an installation script that automates the setup of:
- Nginx as a reverse proxy
- SSL certificates with Certbot
- HTTPS configuration
- SystemD service for automatic restarts
- NVM (Node Version Manager) with the latest stable Node.js version
- Ubuntu server (18.04 or newer)
- A domain name pointing to your server
- Root or sudo access
- Clone this repository to your server
- Edit the
install.shfile to update theDOMAINvariable with your domain name - Make the script executable:
chmod +x install.sh - Run the installation script:
./install.sh
- Installs Nginx, Certbot, and other required dependencies
- Installs NVM (Node Version Manager)
- Uses NVM to install the latest stable Node.js LTS version
- Configures Nginx as a reverse proxy to your Node.js application
- Obtains SSL certificates from Let's Encrypt
- Configures HTTPS
- Creates a SystemD service for your application
- Enables and starts the service
After installation, you can manage your application with these commands:
- Check status:
sudo systemctl status simple-node-server - View logs:
sudo journalctl -u simple-node-server - Restart:
sudo systemctl restart simple-node-server - Stop:
sudo systemctl stop simple-node-server - Start:
sudo systemctl start simple-node-server
If you need to modify the configuration:
- Nginx configuration:
/etc/nginx/sites-available/simple-node-server - SystemD service:
/etc/systemd/system/simple-node-server.service
After modifying the Nginx configuration, run:
sudo nginx -t && sudo systemctl reload nginx
After modifying the SystemD service, run:
sudo systemctl daemon-reload