Monday, September 2, 2024

Setting Up ONLYOFFICE Document Server on Ubuntu 24.04 with HTTPS

ONLYOFFICE Document Server is an online office suite that you can install on your local server. It allows collaborative editing of documents, spreadsheets, and presentations, supporting all popular formats like DOCX, XLSX, and PPTX. This guide will walk you through deploying ONLYOFFICE Document Server on Ubuntu 24.04, using PostgreSQL as the database and Nginx as a reverse proxy. We'll also secure ONLYOFFICE with HTTPS using Certbot and Letsencrypt.

Prerequisites

Before we begin, ensure you have:

  • Ubuntu 24.04 Server: A running instance of Ubuntu 24.04.

  • Non-root User with Administrator Privileges: A user account with administrative rights for your server.

  • Domain Name: A domain name that resolves to your server's IP address.

Installing PostgreSQL and RabbitMQ

ONLYOFFICE Document Server relies on PostgreSQL and RabbitMQ. Let's install these essential components from the official Ubuntu repositories.

  1. Update Package Indices:

    sudo apt update
        
  2. Install PostgreSQL and RabbitMQ:

    sudo apt install postgresql rabbitmq-server

    Confirm the installation by pressing 'Y'.

  3. Check PostgreSQL Status:

    sudo systemctl is-enabled postgresql
    sudo systemctl status postgresql

    You should see PostgreSQL active and running.

  4. Check RabbitMQ Status:

    sudo systemctl is-enabled rabbitmq-server
    sudo systemctl status rabbitmq-server
    

    Verify that RabbitMQ is also running.

Creating a PostgreSQL Database and User

Now, we'll create a dedicated PostgreSQL database and user for ONLYOFFICE.

  1. Create a PostgreSQL User:

    sudo -i -u postgres psql -c "CREATE USER onlyoffice WITH PASSWORD 'onlyoffice';"
       
  2. Create a PostgreSQL Database:

    sudo -i -u postgres psql -c "CREATE DATABASE onlyoffice OWNER onlyoffice;"
  3. Verify Database and User Creation:

    sudo -i -u postgres psql -c "\du"  # List users
    sudo -i -u postgres psql -c "\l"  # List databases

    You should see the 'onlyoffice' user and database listed.

Installing ONLYOFFICE Document Server

With the PostgreSQL and RabbitMQ setup complete, we can proceed with installing ONLYOFFICE Document Server.

  1. Download the GPG Key:

    curl -fsSL https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/onlyoffice.gpg
  2. Add the ONLYOFFICE Repository:

    echo "deb [signed-by=/etc/apt/trusted.gpg.d/onlyoffice.gpg] https://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list
        
  3. Update and Install ONLYOFFICE Document Server:

    sudo apt update && sudo apt install onlyoffice-documentserver

    This command will update the package list, install ONLYOFFICE Document Server, and also install Nginx as the default webserver.

  4. Provide Credentials:

    • Enter 'Y' to proceed with the installation.

    • Enter the PostgreSQL database password ('onlyoffice').

    • Choose 'OK' to accept the TTF mscorefont license.

    • Choose 'Yes' to accept the EULA.

Configuring UFW (Uncomplicated Firewall)

Let's secure our server by setting up UFW and opening the required ports.

  1. Add Firewall Profiles:

    sudo ufw allow OpenSSH
    sudo ufw allow 'Nginx Full'
    

    This opens ports 22 for SSH and 80/443 for Nginx.

  2. Enable UFW:

    sudo ufw enable

    Confirm by entering 'y'.

  3. Check UFW Status:

    sudo ufw status

    You should see UFW active and the 'OpenSSH' and 'Nginx Full' profiles enabled.

Securing ONLYOFFICE with HTTPS

Now, let's secure ONLYOFFICE with HTTPS using Certbot and Letsencrypt. Ensure your domain name is ready and points to your Ubuntu server's IP address.

  1. Stop Nginx:

    sudo systemctl stop nginx
  2. Install Certbot:

    sudo apt install certbot -y
  3. Generate SSL Certificate:

    sudo certbot certonly --standalone -m admin@yourdomain.com --agree-tos --no-eff-email -d yourdomain.com

    Replace admin@yourdomain.com and yourdomain.com with your actual email address and domain name.

    Certbot will generate the SSL certificate and store it in /etc/letsencrypt/live/yourdomain.com. You'll find the public key in fullchain.pem and the private key in privkey.pem.

  4. Configure Nginx for HTTPS:

    • Copy the Nginx template for ONLYOFFICE:

      sudo cp -f /etc/onlyoffice/documentserver/nginx/ds-ssl.conf.tmpl /etc/onlyoffice/documentserver/nginx/ds.conf
    • Edit the Nginx configuration:

      sudo nano /etc/onlyoffice/documentserver/nginx/ds.conf
    • Update the ssl_certificate and ssl_certificate_key paths:

      ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
      ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
      
    • Save and close the file.

  5. Test Nginx Configuration and Restart:

    sudo nginx -t
    sudo systemctl start nginx

    You should see "test successful - syntax OK" if the configuration is correct.

  6. Apply HTTPS to ONLYOFFICE:

    sudo bash /usr/bin/documentserver-update-securelink.sh
     

Verifying the ONLYOFFICE Document Server Installation

Access your ONLYOFFICE installation by visiting your domain name, for example: https://yourdomain.com/. You should see a confirmation message stating that ONLYOFFICE Docs Community Edition is installed.

Now you can integrate ONLYOFFICE with your file servers (Nextcloud, ownCloud), CMS platforms (WordPress, Drupal), or CRMs (Odoo, SuiteCRM).

Conclusion

Congratulations! You have successfully deployed ONLYOFFICE Document Server on your Ubuntu 24.04 server. Your ONLYOFFICE Document Server is now secured with HTTPS, and you can start collaborating on documents, spreadsheets, and presentations within your organization.

0 comments:

Post a Comment