Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities

In the last article we covered the main features of MinIO and how to install it. Let’s take a look at day-to-day administration and reverse proxy using Nginx.

MinIO client

MacOS client installation

Use Homebrew to install the MC

brew install minio/stable/mc
mc --help
Copy the code

Windows client installation

Downloading binaries

Place the downloaded files in a fixed directory such as C:\minio. Configure this directory to environment variables so that CMD command Windows can execute commands directly.

My computer – right – the bottom properties – advanced system Settings – environment variables – system – chosen Path – editor – new – type C: \ minio

Open a CMD window and type MC –help to verify that the installation is successful.

Add a cloud storage service

To add one or more S3 compatible services, refer to the following description. The MC stores all configuration information in the ~/.mc/config.json file.

mc config host add <ALIAS> <YOUR-S3-ENDPOINT> <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY> [--api API-SIGNATURE]
Copy the code

An alias is a shorter nickname for your cloud storage service. S3 Endpoint, Access Key, and Secret Key are provided by your cloud storage service. The API signature is optional and is set to “S3v4” by default.

Example: MinIO cloud storage

Get urls, Access keys, and Secret keys from the MinIO service.

MC config host add myminio http://10.9.2.3:9000 ProEXEC ONRPROEXEC -- API s3V4Copy the code

Check the file

mc ls myminio
Copy the code

Creating a Storage Bucket

mc mb myminio/testbucket
Bucket created successfully `myminio/testbucket`.
Copy the code

Supported commands

Ls Lists files and folders. MB Creates a bucket or folder. Cat displays file and object contents. Pipe redirects a STDIN to an object or file or STDOUT. Share generates the URL for sharing. Cp Copies files and objects. Mirror Mirrors buckets and folders. Find finds files based on parameters. Diff compares differences between two folders or buckets. Rm deleted files and objects. Events Notifications of managed objects. Watch monitors events for files and objects. Policy Manages access policies. Config Manages MC configuration files. Update Checks software updates. Version Displays the version information.Copy the code

Admin Common Commands

Anonymous access

Set can be anonymous access, as a map bed use anonymous access is mostly to enable, the specific command is as follows:

mc policy set public myminio/testbucket
Copy the code

Use the policy:

Name: mc policy - manage anonymous access to buckets and objects USAGE: mc policy [FLAGS] set PERMISSION TARGET mc policy [FLAGS] set-json FILE TARGET mc policy [FLAGS] get TARGET mc policy [FLAGS] get-json TARGET mc policy [FLAGS] list TARGET FLAGS: --recursive, -r list recursively --config-dir value, -C value path to configuration folder (default: "/Users/chenbing/.mc") --quiet, -q disable progress bar display --no-color disable color theme --json enable JSON lines formatted output --debug enable debug output --insecure disable SSL certificate verification --help, -h show help PERMISSION: Allowed policies are: [none, download, upload, public]. FILE: A valid S3 policy JSON filepath. EXAMPLES: 1. Set bucket to "download" on Amazon S3 cloud storage. $ mc policy set download s3/burningman2011 2. Set bucket to "public" on Amazon S3 cloud storage. $ mc policy set public s3/shared 3. Set bucket to "upload" on Amazon S3 cloud storage. $ mc policy set upload s3/incoming 4. Set policy to "public" for bucket with prefix on Amazon S3 cloud storage.  $ mc policy set public s3/public-commons/images 5. Set a custom prefix based bucket policy on Amazon S3 cloud storage using a JSON file. $ mc policy set-json /path/to/policy.json s3/public-commons/images 6. Get bucket permissions. $ mc policy get s3/shared 7. Get bucket permissions in JSON format. $ mc policy get-json s3/shared 8. List policies set to a specified bucket. $ mc policy list s3/shared 9. List public object URLs recursively. $ mc policy --recursive links s3/shared/Copy the code

Add user

mc admin user add myminio/ testuser testuser
mc admin user enable myminio/ testuser
mc admin policy set myminio/ readwrite user=testuser
Copy the code

Nginx reverse proxy configuration

Add the following configuration to your nginx configuration file:

server { listen 80; server_name example.com; location / { proxy_set_header Host $host; proxy_pass http://localhost:9000; }}Copy the code

Note:

  • Replace example.com with your own hostname.
  • Use your own service name insteadhttp://localhost:9000.
  • In order to be able to upload large files, inhttpContext addclient_max_body_size 1000m;, just adjust the value to your needs. The default value is1mToo low for most scenarios.
  • Minio must obtain the host and all header Settings from the HTTP header to verify signature validityproxy_set_header Host $host;Must not omit

conclusion

This article introduces the basic operation of Minio in daily use and how to use it with Nginx. In the next article, I will show you how to use Typora to build your own collaboration tool.