DEV Community

Sahal
Sahal

Posted on

Tutorial: Deploy OwnCloud on GCP with Docker & NGINX (Step-by-Step)

Hey Devs ๐Ÿ‘‹,

In this post, Iโ€™ll guide you through deploying OwnCloud on a GCP VM instance using Docker, secured with NGINX as a reverse proxy and HTTPS enabled via Let's Encrypt.


๐Ÿงฐ What Youโ€™ll Need

  • Google Cloud Platform (GCP) account
  • Basic Linux & Docker knowledge
  • Domain name (e.g., ceritadesain.com)
  • SSH access to your VM

๐Ÿ“ฆ Step 1: Create a GCP VM Instance

  1. Go to Google Cloud Console
  2. Navigate to: Compute Engine > VM instances
  3. Create a new instance:
    • OS: Ubuntu 22.04 LTS
    • Firewall: Allow HTTP & HTTPS
  4. SSH into your instance once itโ€™s running.

๐Ÿณ Step 2: Install Docker & Docker Compose

sudo apt update
sudo apt install docker.io docker-compose -y
sudo systemctl enable docker
sudo usermod -aG docker $USER
Enter fullscreen mode Exit fullscreen mode

๐Ÿ” Logout and login again to apply Docker group permissions.


๐Ÿ“ Step 3: Setup OwnCloud with Docker Compose

Create a folder for the project:

mkdir owncloud-docker && cd owncloud-docker
Enter fullscreen mode Exit fullscreen mode

Create a docker-compose.yml:

version: '3.1'

services:
  owncloud:
    image: owncloud/server
    restart: always
    ports:
      - 8080:8080
    environment:
      - OWNCLOUD_DOMAIN=ceritadesain.com
      - OWNCLOUD_ADMIN_USERNAME=admin
      - OWNCLOUD_ADMIN_PASSWORD=yourpassword
    volumes:
      - files:/mnt/data

volumes:
  files:
Enter fullscreen mode Exit fullscreen mode

Run:

docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

You can now access it at http://your-external-ip:8080.


๐ŸŒ Step 4: Point Your Domain to the VM IP

On your domain provider, update the A record to point to your GCP VM's external IP.

Example:

A  @  ->  34.100.xxx.xxx
Enter fullscreen mode Exit fullscreen mode

๐Ÿ” Step 5: Setup NGINX Reverse Proxy + SSL

Install NGINX and Certbot:

sudo apt install nginx certbot python3-certbot-nginx -y
Enter fullscreen mode Exit fullscreen mode

Create an NGINX config:

sudo nano /etc/nginx/sites-available/owncloud
Enter fullscreen mode Exit fullscreen mode

Paste this:

server {
    listen 80;
    server_name ceritadesain.com;

    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
Enter fullscreen mode Exit fullscreen mode

Enable it:

sudo ln -s /etc/nginx/sites-available/owncloud /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode

Add HTTPS via Certbot:

sudo certbot --nginx -d ceritadesain.com
Enter fullscreen mode Exit fullscreen mode

Done! ๐ŸŽ‰ Now your OwnCloud is accessible via https://ceritadesain.com


๐Ÿง  Bonus Tips

  • Use Docker volumes for persistent data.
  • Set up automatic SSL renewal with:
  sudo crontab -e
Enter fullscreen mode Exit fullscreen mode

Add:

  0 0 * * * certbot renew --quiet
Enter fullscreen mode Exit fullscreen mode

๐Ÿค Letโ€™s Connect!

If you found this helpful, feel free to comment or connect with me on LinkedIn or GitHub. I'm always up for feedback or collaboration on DevOps, web, and ML projects.


Top comments (0)