Skip to content

missuo/discord-image

Repository files navigation

GitHub Workflow Go Version

Powerful image hosting / file sharing implemented using Discord Bot.

Deployment requires applying for a Discord account and creating a bot to obtain a Bot Token. However, this article will not mention these steps. Please Google how to do it yourself.

Features

  • Maximum supported single file size: 25MB.
  • Files never expire.
  • Support viewing upload history, support deleting file.
  • Support for uploading images, videos, and other files.
  • Support custom proxy url.
  • Support automatic deletion of files after uploading to the server, will not occupy your server's hard disk.
  • Support private deployment, secure and reliable.

Start with Docker

mkdir discord-image && cd discord-image
wget -O compose.yaml https://raw.githubusercontent.com/missuo/discord-image/main/compose.yaml
nano compose.yaml
docker compose up -d

Nginx Reverse Proxy

location / {
    proxy_pass http://localhost:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_http_version 1.1;
} 

Config files and environment variables

You can leave proxy_url unset, but the domain of Discord cannot be accessed in mainland China. If you want to access Discord in mainland China, you must configure this option. How to deploy the proxy url, please continue to read below.

bot:
  token: "" # Discord bot token
  channel_id: "" # Channel ID

upload:
  temp_dir: "uploads" # Temporary directory for storing files

proxy_url: example.com # Custom proxy url for cdn.discordapp.com
auto_delete: true # Automatically delete files after uploading to the server
services:
  discord-image:
    images: ghcr.io/missuo/discord-image
    ports:
      - "8080:8080"
    environment:
      - BOT_TOKEN=your_bot_token
      - CHANNEL_ID=your_channel_id
      - UPLOAD_DIR=/app/uploads
      - PROXY_URL=your_proxy_url
      - AUTO_DELETE=true
    volumes:
      - ./uploads:/app/uploads

Deploy proxy url

If you are using Nginx, you can use the following configuration:

location /
{
    proxy_pass https://cdn.discordapp.com;
    proxy_set_header Host cdn.discordapp.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_http_version 1.1;
}

Of course, you can use serverless tools like Cloudflare Workers to deploy Proxy URL.

License

AGPL-3.0