8000 GitHub - sgh370/rancher: This repository contains a Docker Compose configuration for setting up Rancher on an Ubuntu server with Caddy as a reverse proxy, optimized for Cloudflare's Full SSL mode.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ rancher Public

This repository contains a Docker Compose configuration for setting up Rancher on an Ubuntu server with Caddy as a reverse proxy, optimized for Cloudflare's Full SSL mode.

Notifications You must be signed in to change notification settings

sgh370/rancher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rancher with Caddy Reverse Proxy Setup (Cloudflare Full SSL)

This repository contains a Docker Compose configuration for setting up Rancher on an Ubuntu server with Caddy as a reverse proxy, optimized for Cloudflare's Full SSL mode.

Author

Saeed Ghanbari - GitHub

Prerequisites

  • Ubuntu server with Docker and Docker Compose installed
  • Domain name configured in Cloudflare with "Full" SSL option
  • Cloudflare API token (if using DNS validation)

Installation

  1. Make sure Docker and Docker Compose are installed on your Ubuntu server:
# Install Docker if not already installed
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io

# Install Docker Compose if not already installed
sudo curl -L "https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
  1. Create the external Docker network:
sudo docker network create rancher-network
  1. Start Rancher using Docker Compose:
# Navigate to the directory containing docker-compose.yml
cd /path/to/rancher

# Start Rancher
sudo docker-compose up -d
  1. Start Caddy using the provided docker-compose.caddy.yml:
# Start Caddy
sudo docker-compose -f docker-compose.caddy.yml up -d
  1. Access Rancher UI:
    • Open your browser and navigate to https://your-domain.com
    • The first time you access Rancher, you'll be prompted to set a password and the server URL
    • For the server URL, make sure to use your domain: https://your-domain.com

Cloudflare Configuration

This setup is optimized for Cloudflare's "Full" SSL mode, which means:

  1. Cloudflare handles SSL from the visitor to Cloudflare
  2. Caddy handles SSL from Cloudflare to your server

To configure Cloudflare correctly:

  1. In your Cloudflare dashboard, go to the SSL/TLS section
  2. Set the encryption mode to "Full"
  3. Make sure your domain's DNS records point to your server's IP address
  4. Recommended: Enable "Always Use HTTPS" in the SSL/TLS > Edge Certificates section

Configuration Files

docker-compose.yml

The main Rancher configuration file that:

  • Uses the external rancher-network network
  • Exposes ports 80 and 443 internally (not to the host)
  • Sets up volumes for data persistence
  • Configures Rancher with appropriate environment variables

docker-compose.caddy.yml

The Caddy configuration file that:

  • Uses the same external rancher-network network
  • Publishes ports 80 and 443 to the host
  • Mounts the Caddyfile and data directories
  • Configures Caddy with appropriate environment variables

Caddyfile

The Caddy server configuration that:

  • Sets up reverse proxy to Rancher
  • Configures TLS for Cloudflare Full SSL mode
  • Handles WebSocket connections
  • Sets up proper logging

Configuration Options

Rancher Configuration

The docker-compose.yml includes several environment variables that you can customize:

  • CATTLE_BOOTSTRAP_PASSWORD: Initial admin password
  • CATTLE_SERVER_URL: Set this to your domain
  • CATTLE_SYSTEM_DEFAULT_REGISTRY: Set default private registry if needed
  • CATTLE_AGENT_IMAGE: Specify agent image
  • AUDIT_LEVEL: Audit log level (0=off, 1=minimal, 2=medium, 3=full)
  • CATTLE_MEMORY_LIMIT: Memory limit for Rancher
  • CATTLE_PROMETHEUS_METRICS: Enable Prometheus metrics
  • CATTLE_DEBUG: Enable debug mode (for troubleshooting only)

Data Persistence

The configuration uses Docker volumes to persist Rancher data:

  • rancher-data: Stores all Rancher data
  • rancher-audit-log: Stores audit logs if enabled

Upgrading Rancher

To upgrade to a newer version of Rancher:

# Pull the latest image
sudo docker-compose pull

# Restart with the new image
sudo docker-compose up -d

Backup and Restore

To manually back up Rancher data:

# Create a backup directory
mkdir -p backups

# Create a backup
sudo docker run --rm -v rancher_rancher-data:/var/lib/rancher:ro -v $(pwd)/backups:/backups alpine tar -czf /backups/rancher-backup-$(date +%Y%m%d-%H%M%S).tar.gz /var/lib/rancher

Additional Resources

About

This repository contains a Docker Compose configuration for setting up Rancher on an Ubuntu server with Caddy as a reverse proxy, optimized for Cloudflare's Full SSL mode.

Resources

Stars

Watchers

Forks

Languages

0