Create EC2 instance:
linux/ubuntu 20.04
MINIMUM 2GB RAM
Click create
Make sure to add 443 port in security groups
Create Cloudflare domain pointing at server IP address, proxy status - DNS ONLY
SSH to instance and follow instructions:
sudo apt-get update -y
sudo apt-get install -y build-essential certbot nginx python3-certbot-nginx
Set environment variables
Install Node.js, NPM, PM2, N8N
curl -L https://bit.ly/n-install | bash -s -- -y lts
source ~ /.bashrc
npm i -g npm n8n pm2
sudo bash -c " cat > /etc/nginx/sites-available/$AUTOMATION_HOST " << EOF
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name $AUTOMATION_HOST ;
location / {
proxy_pass http://localhost:5678;
proxy_http_version 1.1;
proxy_set_header Connection '';
proxy_set_header Host \$ host;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
}
EOF
sudo ln -s /etc/nginx/sites-available/$AUTOMATION_HOST /etc/nginx/sites-enabled/
sudo systemctl restart nginx
sudo certbot --nginx --agree-tos --redirect -d $AUTOMATION_HOST -m $TECH_EMAIL -n
Start n8n and configure launch on server reboot
pm2 start n8n
cat > ecosystem.config.js << EOF
module.exports = {
apps: [{
name: "n8n",
env: {
N8N_PROTOCOL: "https",
N8N_HOST: "$AUTOMATION_HOST ",
WEBHOOK_URL: "https://$AUTOMATION_HOST /"
}
}]
}
EOF
pm2 start ecosystem.config.js
sudo env PATH=$PATH :/home/ubuntu/n/bin /home/ubuntu/n/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu
pm2 save