RustFS S3 兼容对象存储

sudo chown -R 10001:10001 /opt/rustfs/data sudo chown -R 10001:10001 /opt/rustfs/logs

services:
  rustfs:
    image: rustfs/rustfs:latest
    container_name: rustfs
    restart: unless-stopped

    ports:
      - "9000:9000"
      - "9001:9001"

    environment:
      RUSTFS_ACCESS_KEY: "RUSTFSADMIN"
      RUSTFS_SECRET_KEY: "Shingi@2023"

      RUSTFS_ADDRESS: ":9000"
      RUSTFS_CONSOLE_ADDRESS: ":9001"
      RUSTFS_CONSOLE_ENABLE: "true"

    volumes:
      - /opt/rustfs/data:/data
map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      '';
}

upstream rustfs_s3 {
    server 127.0.0.1:9000;
    keepalive 32;
}

upstream rustfs_console {
    server 127.0.0.1:9001;
    keepalive 16;
}


# HTTP → HTTPS
server {
    listen 80;
    listen [::]:80;

    server_name s3.example.com console.example.com;

    return 301 https://$host$request_uri;
}


# =========================
# RustFS S3 API
# =========================

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name s3.example.com;

    ssl_certificate /etc/letsencrypt/live/catpd.cn/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/catpd.cn/privkey.pem;

    # S3 上传文件大小不限制
    client_max_body_size 0;

    # S3 流式上传非常重要
    proxy_buffering off;
    proxy_request_buffering off;

    ignore_invalid_headers off;

    location / {

        proxy_http_version 1.1;

        proxy_set_header Host $http_host;

        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;

        proxy_set_header Connection "";

        proxy_connect_timeout 300s;

        proxy_read_timeout 300s;

        proxy_send_timeout 300s;

        proxy_cache_convert_head off;

        chunked_transfer_encoding off;

        proxy_pass http://localhost:9000;
    }
}


# =========================
# RustFS Console
# =========================

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name console.example.com;

    ssl_certificate /etc/letsencrypt/live/catpd.cn/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/catpd.cn/privkey.pem;

    client_max_body_size 0;

    proxy_buffering off;
    proxy_request_buffering off;

    location / {

        proxy_http_version 1.1;

        proxy_set_header Host $http_host;

        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;

        # Console WebSocket
        proxy_set_header Upgrade $http_upgrade;

        proxy_set_header Connection $connection_upgrade;

        proxy_connect_timeout 300s;

        proxy_read_timeout 300s;

        proxy_send_timeout 300s;

        proxy_pass http://localhost:9001;
    }
}