Skip to main content

Installation Guide

This guide will walk you through installing and configuring CyberPaste on your server.

Prerequisites

Before installing CyberPaste, ensure you have the following:

Step 1: Clone the Repository

git clone https://github.com/lollopanta/CyberPaste.git
cd CyberPaste

Step 2: Install Dependencies

npm install

This will install all required dependencies including Express.js, MongoDB, Passport.js, and other packages.

Step 3: Set Up MongoDB

Option A: Local MongoDB

  1. Install MongoDB on your system

  2. Start MongoDB service:

    # Linux (systemd)
    sudo systemctl start mongod

    # macOS (Homebrew)
    brew services start mongodb-community

    # Windows
    # Start MongoDB from Services or use mongod.exe
  3. Verify MongoDB is running:

    mongosh

Option B: MongoDB Atlas (Cloud)

  1. Create an account at MongoDB Atlas
  2. Create a new cluster
  3. Create a database user
  4. Whitelist your server IP address
  5. Get your connection string

Step 4: Configure Discord OAuth

  1. Go to Discord Developer Portal
  2. Click "New Application" and give it a name
  3. Go to "OAuth2" → "General"
  4. Add a redirect URI:
    • For local development: http://localhost:3000/auth/discord/callback
    • For production: https://yourdomain.com/auth/discord/callback
  5. Copy the "Client ID" and "Client Secret"
  6. Save the application

Step 5: Configure CyberPaste

Create or edit the config.yml file in the root directory:

# License Configuration
licenseKey: 'YOUR_LICENSE_KEY' # Replace with your actual license key

# Database Configuration
mongoURI: 'mongodb://localhost:27017/CyberPaste' # Or your MongoDB Atlas connection string

# Owner Configuration
OwnerID: 'YOUR_DISCORD_USER_ID' # Your Discord User ID (enable Developer Mode to get it)

# Debug Mode
debug: false # Set to true for development, false for production

# Web Server Configuration
baseURL: 'http://localhost:3000' # Your domain URL (no trailing slash)
Port: 3000 # Server port
useSSL: false # Set to true if using HTTPS (requires reverse proxy)

# Discord OAuth Configuration
clientId: 'YOUR_DISCORD_CLIENT_ID'
clientSecret: 'YOUR_DISCORD_CLIENT_SECRET'

# Session Configuration
sessionTime: '7d' # Session duration (e.g., 1h, 7d, 30d)
sessionSecret: 'YOUR_SECURE_SESSION_SECRET' # Generate a secure random string

Getting Your Discord User ID

  1. Enable Developer Mode in Discord:
    • Settings → Advanced → Developer Mode
  2. Right-click on your username (in any server or DM)
  3. Click "Copy User ID"
  4. Paste it as OwnerID in config.yml

Generating a Session Secret

Generate a secure random string for sessionSecret:

# Linux/macOS
openssl rand -base64 32

# Or use an online generator
# https://www.dashlane.com/features/password-generator

Step 6: Start the Application

npm start

The application should start and you'll see:

[INFO] MongoDB connected
[INFO] Model loaded: Paste
[INFO] Model loaded: Settings
[INFO] Model loaded: Statistics
[INFO] Model loaded: User
[LICENSE] Validating license on startup...
[LICENSE] License validated successfully on startup!
[LICENSE] Periodic validation started (every 15 minutes)
[INFO] Server started on port 3000
[INFO] Access the application at http://localhost:3000

Step 7: Access the Application

Open your browser and navigate to:

  • Homepage: http://localhost:3000
  • Admin Panel: http://localhost:3000/staff (requires owner login)

Production Deployment

  1. Install PM2 globally:

    npm install -g pm2
  2. Start the application:

    pm2 start index.js --name CyberPaste
  3. Save the PM2 process list:

    pm2 save
  4. Set up PM2 to start on boot:

    pm2 startup

Using Docker

Create a Dockerfile:

FROM node:18-alpine

WORKDIR /app

COPY package*.json ./
RUN npm install --production

COPY . .

EXPOSE 3000

CMD ["node", "index.js"]

Build and run:

docker build -t cyberpaste .
docker run -d -p 3000:3000 --name cyberpaste cyberpaste

Reverse Proxy with Nginx

Configure Nginx as a reverse proxy:

server {
listen 80;
server_name paste.example.com;

location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

SSL/HTTPS Setup

  1. Install Certbot:

    sudo apt-get install certbot python3-certbot-nginx
  2. Obtain SSL certificate:

    sudo certbot --nginx -d paste.example.com
  3. Update config.yml:

    baseURL: 'https://paste.example.com'
    useSSL: true

Troubleshooting

Application won't start

  • Check Node.js version: node --version (must be 18+)
  • Verify MongoDB is running: mongosh
  • Check config.yml for errors
  • Review console output for error messages

MongoDB connection error

  • Verify MongoDB is running
  • Check connection string in config.yml
  • Ensure MongoDB is accessible from your server
  • Check firewall rules
  • Verify credentials are correct

Discord OAuth not working

  • Verify Client ID and Client Secret in config.yml
  • Check redirect URI matches exactly in Discord Developer Portal
  • Ensure redirect URI uses correct protocol (http/https)
  • Verify Discord application is not restricted

License validation failed

  • Verify license key is correct in config.yml
  • Check internet connection (license server must be accessible)
  • Ensure license key is valid and not expired
  • Contact support if issues persist

Next Steps

  • Configure your admin panel settings
  • Customize your site branding
  • Set up rate limits and security settings
  • Review the API Reference for integration
  • Check the FAQ for common questions

Need Help? Join our Discord server for support and assistance.