Skip to content

Instantly share code, notes, and snippets.

@mikamboo
Last active August 14, 2023 11:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikamboo/bef6dd6501a16cf977ad6c4ffa6a29f9 to your computer and use it in GitHub Desktop.
Save mikamboo/bef6dd6501a16cf977ad6c4ffa6a29f9 to your computer and use it in GitHub Desktop.
Serve files using MiniIO + Ngrok

MinIO Object Storage + Ngrok HTTPS url

Create in less than 5 minutes an Object Storage with local files exposed via HTTPS public URL. In this tutorial I use Docker to quickly run MinIO server, and ngrok to easily share files from local machine without messing with DNS and firewall settings.

Summary in two commands:

docker run --rm -p 9000:9000 \
  -v /tmp/local-data:/data \
  -e "MINIO_ACCESS_KEY=EXAMPLE_ACCESS_KEY" \
  -e "MINIO_SECRET_KEY=EXAMPLE_SECRET_KEY" \
  minio/minio server /data

./ngrok http 9000  

Read following step by step guide for explanations ...

Prequistes

  • Download ngrok
  • Docker for minio (install alternatives without docker exists, read the doc)

Step 0 : Download and init ngrok

  1. Download link: https://ngrok.com/download
  2. Authenticate yourself to ngrok
  3. Run following command over dowloaded ngrok binary file
./ngrok authtoke XXXXXX

Where XXXXXX is your account auth token. More on ngrok doc

Step 1 : Create MinIO server using Docker

mkdir /tmp/local-data

docker run --rm -p 9000:9000 \
  -v /tmp/local-data:/data \
  -e "MINIO_ACCESS_KEY=EXAMPLE_ACCESS_KEY" \
  -e "MINIO_SECRET_KEY=EXAMPLE_SECRET_KEY" \
  minio/minio server /data
  • NB : Replace EXAMPLE_ACCESS_KEY / EXAMPLE_SECRET_KEY with our more secure values.
  • NB : Replace /tmp/data with path of directory where you put files to share

Test using MinIO Browser:

Point your web browser to http://127.0.0.1:9000 to ensure your server has started successfully.

Step 2 : Connect to MinIO and create a bucket

From your web browser, go to http://127.0.0.1:9000, enter your EXAMPLE_ACCESS_KEY + EXAMPLE_SECRET_KEY (provided to server on previous step) as athentication credentials.

image

When you are connected on MinIO web app, create a bucket ex: bucket01

image

Step 3 : Expose the MinIO serve

Expose the MinIO server which is running on port 9000 by runnin following CMD :

cd /to-dir/of-ngrok/downloaded-file

./ngrok http 9000

The command will display a generated url like https://6441f740aac1.ngrok.io wich exposed the local MinIO web server.

image

NOTICE : You can replace ngrok with altenative solutiions like localtunnel

Links

@mikamboo
Copy link
Author

mikamboo commented Dec 12, 2020

Captures

Auth page
image

My first bucket
image

Ngrok running
image

@dungnguyenBKA
Copy link

Hi @mikamboo, great work!
I want to combine ngrok service and minio in single docker-compose file. I'm try to archive that, but I got error:

ERR_NGROK_3200
Tunnel not found

This is my docker-compose.yml file:

version: '3.7'

services:
  minio:
    image: minio/minio
    ports:
      - "9000:9000"
      - "9090:9090"
    volumes:
      - minio_storage:/data
    environment:
      MINIO_ROOT_USER: ROOTUSER
      MINIO_ROOT_PASSWORD: CHANGEME123
    command: server --console-address ":9090" /data
  ngrok:
        image: ngrok/ngrok:latest
        restart: unless-stopped
        command:
          - "start"
          - "--all"
          - "--config"
          - "/etc/ngrok.yml"
        volumes:
          - ./ngrok.yml:/etc/ngrok.yml
        ports:
          - 4040:4040
volumes:
  minio_storage: {}

This is my ngrok.yml config file which is in the same folder with docker-compose:

authtoken: <MY_TOKEN>
version: 2
tunnels:
  minio_web:
    proto: http
    hostname: <MY_HOST_NAME>
    addr: 127.0.0.1:9090

I guess the error is because of networking in docker, I'll learn more about that and may update the comment in the future~~ But if you know how to fix that please reply to this comment :v
Have a good day~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment