How to install minio on Windows 10 with valid SSL certificate
In this guide we’ll walk through the steps of installing an Amazon S3 compatible service on Windows 10 using minio, a cross-platform implementation of the S3 API.
While minio has a client and an SDK library as well, we’ll only focus on the server side component for now.
Our goals
- install a fully S3 compatible service
- start automatically on system startup
- transport should be protected by a valid SSL certificate (for free)
Using minio you’ll be able to implement secure backup easily between Windows workstations which is very similar to the capabilities CrashPlan had.
Assumptions in this guide
- minio will run on Windows 10
- computer is accessible on TCP port
9000
over the internet - application files and scripts will be placed to
E:\minio\
- buckets will be stored in
E:\minio-data\
- nssm will be installed to
E:\nssm\
- duplicati will backup data to a bucket called
duplicati-test
- the service will be run as a local administrator user called
sysadmin
. Its home directory isC:\Users\sysadmin\
- the computer’s public IP address is
111.111.111.111
Additional assumptions for SSL
- free DNS is provided by duckdns.org
- the DNS name is
minio-belidzs.example.com
and it points to111.111.111.111
All of the suggestions above can (and should) be replaced by your own values as long as the change is consistent throughout this guide.
Running the service as an admin user is not required. However you’ll need to have admin rights at least during the installation of the service.
Download and run
- Create a directory for the application:
E:\minio\
- Create a directory for the data:
E:\minio-data\
- Download minio for Windows x64 or minio for Windows x32 to
E:\minio\
Verification
- Open a command prompt as user
sysadmin
. Either log in assysadmin
, or hitWindows
to open Start menu and typecmd
then hitCTRL + SHIFT + Enter
. This will open console assysadmin
. Provide its credentials if needed. - Go to the application directory:
cd E:\minio\
- Start minio:
minio.exe server E:\minio-data
- Note the location of the configuration files, you’ll need it later:
Created minio configuration file successfully at C:\Users\sysadmin\.minio
- Note
AccessKey
andSecretKey
. These will be needed later on. - Open a browser on the local computer, and open minio’s web interface
- Use
AccessKey
andSecretKey
from above to log in - Click on the red plus sign in the lower right part of the web page
- Click on
Create bucket
and enterduplicati-test
- Refresh browser and make sure you’re in
duplicati-test
bucket - Click on the red plus sign in the lower right part of the web page
- Click on
Upload a file
and select an arbitrary file - Check in the file system that the test file was successfully uploaded to
E:\minio-data\duplicati-test
with Windows Explorer, Total Commander or any other suitable tool
Accessing remotely
You need to make sure you can access your service from the computer you want to send backup from.
You’ll need to use the public IP of your computer which you can find out here: dyndns.
- If it says
111.111.111.111
then writehttp://111.111.111.111:9000
into the browser’s address bar on the client computer - Log in with the
AccessKey
andSecretKey
from the previous chapter - Try to download the file you’ve just uploaded
If you cannot access minio, you might need to enable inbound TCP port 9000 on your firewall. This is usually setup by minio itself on its first startup.
If you’re behind NAT, you’ll probably have to set up port forwarding. Search Google on how to do this.
Note
If you want to use minio on a different port (eg. 9001), add the following command line option: --address :9001
Installing as a service
We’re going to use the excellent nssm to convert minio to a regular Windows service.
- Create a directory for nssm:
E:\nssm\
-
Download nssm and unzip the appropriate version of
nssm.exe
to this directory - Open a command prompt as user
sysadmin
. Either log in assysadmin
, or hitWindows
to open Start menu and typecmd
then hitCTRL + SHIFT + Enter
. This will open console as admin. Provide any credentials if needed. - Go to nssm’s directory:
cd E:\nssm\
- Install service:
nssm.exe install Minio E:\minio\minio.exe server E:\minio-data\
- Open services: Hit
Windows
to open Start Menu, typeservices
and hitCTRL + SHIFT + Enter
. Provide administrator credentials if required - Find
minio
and double-click on its name to open properties - Set
Startup type
toAutomatic
- Change to
Log On
tab and make sure that minio will run as the user you want it to (sysadmin
) - Close the properties window
- Stop minio if it’s still running (
CTRL+C
) - Start minio as service: Right click on the service name and
Start
Congratulations, you have just installed an unsecured S3 compatible service on Windows.
Verification
- Restart computer
- Access minio locally
- Upload a file
- Access minio remotely
- Download a file
Get valid SSL certificate to secure network transport
This covers an advanced topic which requires a lot of work to implement but I think it’s always a good idea to protect sensitive data in transport.
If you decide not to proceed further, your files’ confidentiality will still be protected, meaning no one will be able to look into your archives (as long as you let duplicati encrypt your archives) however, your AccessKey
will be revealed to the public in the HTTP headers.
While SecretKey
is not travelling directly in the stream, people with enough computing resource can relatively easily deduce it from your network traffic, which means they could be able to gain access to and delete your backup files.
A valid SSL certificate not only encrypts your whole traffic between the client and the server, but also guarantees that the host you are talking to is actually the host who owns the DNS name you are connecting to. So you are not uploading backup files to an unknown server.
Subdomain registration
If you don’t have a DNS name pointing to your IP address yet, you have to create one for the certificate. Fortunately it can be easily done for free on duckdns.org
- Register on duckdns.org using any method offered
- Type your chosen subdomain:
minio-belidzs
and clickadd domain
- Update current IP if needed
- Verify in a browser if you can access to minio using its DNS name you have just created:
http://minio-belidzs.example.com:9000
Install Bash on Ubuntu on Windows
This will install a Linux-like subsystem in your OS with the exception of the actual Linux kernel. Learn more about this innovation of Microsoft.
- Open PowerShell as an administrator: Hit
Windows
to open Start Menu, typepowershell
and hitCTRL + SHIFT + Enter
. Provide any administrator credentials if required - Run this command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
- Restart your computer when prompted.
Install acme.sh
acme.sh is an ACME client written in Bash. It implements the ACME protocol which is used to verify domain ownership and to download valid SSL certificates from Let’s Encrypt.
Verification has many forms. In this guide we will use duckdns.org’s API to serve a temporary TXT
record as a form of verification. This is probably the easiest way to do it, because otherwise you might have to open tcp ports 80
or 443
which complicates things.
- Open a command prompt as user
sysadmin
. Either log in assysadmin
, or hitWindows
to open Start menu and typecmd
then hitCTRL + SHIFT + Enter
. Provide credentials ofsysadmin
if needed. - Run
bash
- If this is your first time starting Bash on Ubuntu on Windows, create a new user inside Ubuntu, preferably using the same name as in Windows:
sysadmin
- Run this command to install acme.sh:
curl https://get.acme.sh | sh
- Close and reopen Bash so the alias is activated
- Execute
acme.sh
inside Bash to see if installation was successful
Get SSL certificate
- Determine your minio configuration directory. It was displayed when you first started it:
C:\Users\sysadmin\.minio\
- Open a command prompt as user
sysadmin
. Either log in assysadmin
, or hitWindows
to open Start menu and typecmd
then hitCTRL + SHIFT + Enter
. Providesysadmin
's credentials if needed. - Run
bash
- Open a browser and log in to duckdns.org
- Copy your token from the main page
- Export token as a Bash variable by executing this command:
export DuckDNS_Token="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
- Check if your environment variable was successfully created in Bash:
echo $DuckDNS_Token
- Get your certificate files and automatically copy them to minio’s configuration directory with the following command (please change domain name and
/mnt/c/Users/sysadmin/.minio/
if needed):
acme.sh --issue --dns dns_duckdns --domain minio-belidzs.example.com --key-file /mnt/c/Users/sysadmin/.minio/certs/private.key --fullchain-file /mnt/c/Users/sysadmin/.minio/certs/public.crt
- Restart minio service
- Test your new certificate by visiting
https://minio-belidzs.example.com:9000
(note that this is now https instead of plain http)
Great, now your minio service is SSL protected!
However, Let’s Encrypt certificates are only valid for 90 days. Going through the process above every 3 month is not very efficient, so let’s automate the renewal process!
Setting up automatic renewal
The following script runs acme.sh to automagically renew certificate but only if it’s necessary.
In case it is time to renew, touch
will create an empty file called renewed
in your minio folder.
If renewed
file exists, the script will restart minio service to reload certificates, then deletes the file.
- Copy and paste this script into
E:\minio\renew-cert.bat
(customize if neccessary):
@echo off
%windir%\system32\bash.exe -l "/home/sysadmin/.acme.sh"/acme.sh --cron --home "/home/sysadmin/.acme.sh" --renew-hook "/usr/bin/touch /mnt/e/minio/renewed"
if exist E:\minio\renewed (
net stop minio
net start minio
del E:\minio\renewed
)
- You can test if it’s working correctly by adding the
--force
parameter to the end of acme.sh command to force issuing new certificates each time.
Note that Let’s Encrypt has a throttling policy in place so issuing too many certificates too quickly will get you banned from their service for a while. While you are testing, you can add--test
parameter to the command so that your request will go to the staging server instead of the production. While the issued certificates are invalid, you can issue as many as you need without getting banned. - Open Task Scheduler as administrator. Open Start Menu then start typing
Task Scheduler
then hitCTRL+SHIFT+Enter
. Provide an administrator’s credentials. - Right click on
Task Scheduler Library
, thenCreate Task...
- Name:
renew-cert
- Make sure running user is the same who created the Bash environment:
sysadmin
. If not, click onChange User or Group
- Check
Run whether user is logged on or not
- On
Triggers
click onNew...
- Set
Daily
and select a random time.
Keep in mind that whenever a certificate is due to renewal, the service will be stopped for a few seconds - On
Actions
clickNew...
-
Browse...
for your script’s location:E:\minio\renew-cert.bat
- Save your task and you’re done
- You can run a test again by running the task manually
Configuring Duplicati to use your own S3 server
- Add a new backup
- Name:
Test
- Encryption and passphrase: anything you like
- Storage type:
S3 Compatible
- Use SSL:
check
(only if you have activated SSL in minio) - Server:
Custom server url
- Custom S3 endpoint:
minio-belidzs.example.com:9000
- Bucket name:
duplicati-test
- AWS Access ID: your minio’s
AccessKey
- AWS Access Key: your minio’s
SecretKey
- Open
Advanced options
- Add advanced option:
s3-ext-forcepathstyle
and check it. This is always required by minio - Add advanced option:
allowed-ssl-versions
, holdControl
and selectTls12
too. This is only needed if you run Duplicati as a service. Read more about this issue here - Click
Test Connection
- Proceed as usual
If test succeeded you can run a backup task to see if files are actually uploaded to E:\minio-data\
.
By default at the end of every backup task there is a verification when a few random files are downloaded from the storage and checked for integrity. It is a very good test to see if the storage actually works and if it can be trusted with your data.