# Caddyfile

# Gitea - Code Hosting

git.ccktgp.online {
    reverse_proxy gitea:3000 {
        header_up Host {host}
        header_up X-Real-IP {remote}
        header_up X-Forwarded-For {remote}
        header_up X-Forwarded-Proto {scheme}
    }
}


plex.ccktgp.online {
    # Reverse proxy to Plex
    reverse_proxy plex:32400 {
        # Plex specific headers
        header_up X-Real-IP {remote_host}
        header_up X-Forwarded-For {remote_host}
        header_up X-Forwarded-Proto {scheme}
        
        # Plex authentication headers
        header_up X-Plex-Client-Identifier {http.request.header.X-Plex-Client-Identifier}
        header_up X-Plex-Device {http.request.header.X-Plex-Device}
        header_up X-Plex-Device-Name {http.request.header.X-Plex-Device-Name}
        header_up X-Plex-Platform {http.request.header.X-Plex-Platform}
        header_up X-Plex-Platform-Version {http.request.header.X-Plex-Platform-Version}
        header_up X-Plex-Product {http.request.header.X-Plex-Product}
        header_up X-Plex-Token {http.request.header.X-Plex-Token}
        header_up X-Plex-Version {http.request.header.X-Plex-Version}
    }
    
}

# Immich - Photo Backup & Gallery
photo.ccktgp.online {
    # Main app and API
    reverse_proxy immich-server:2283 {
        header_up Host {host}
        header_up X-Real-IP {remote}
        header_up X-Forwarded-For {remote}
        header_up X-Forwarded-Proto {scheme}
    }
    
    # Microservices (if needed)
    @machinelearning {
        path /api/activities/* /api/jobs/* /api/search/*
    }
    reverse_proxy @machinelearning immich-server:2283
}

# Navidrome - Music Server
music.ccktgp.online {
    reverse_proxy navidrome:4533

    # WebSocket for real-time updates
    @websockets {
        path /ws
    }
    reverse_proxy @websockets navidrome:4533
}

# Nextcloud - File Sync & Collaboration
files.ccktgp.online {
    reverse_proxy nextcloud:80 {
        header_up Host {host}
        header_up X-Real-IP {remote}
        header_up X-Forwarded-For {remote}
        header_up X-Forwarded-Proto {scheme}
    }

    # Client endpoints for better performance
    @client {
        path /remote.php/dav/files/* /remote.php/webdav/*
    }
    reverse_proxy @client nextcloud:80 {
        transport http {
            read_timeout 3600s
        }
    }
}
