Prismjs

Google Drive download page with Nginx and rclone

After writing using rclone to mount services such as Google Drive on Linux, it occurred to me that there are a lot of ways to play around with the ability to mount Google Drive and other netbooks. One of the ways to do this is to combine it with a web server such as Nginx to make a convenient download page.

Prepare

Download page to implement the main use of Nginx and Nginx provides a number of features .
These include automatic search and authentication.

Configuration

By default, Nginx indexes directories and returns 403. bash'' autoindex on; The autoindex mode can be successfully started after reloading.

If you are successful, you will need to configure authentication, otherwise you can download files from the netbook as long as you know the address.
Nginx provides us with a very simple way to configure ‘basic auth’:

printf "user:$(openssl passwd -crypt passwd)\n" >> /etc/nginx/conf.d/passwd

where user is your account, passwd is your password, and /etc/nginx/conf.d/passwd is the generated authentication file.
Then add the following to your Nginx configuration file bash'' auth_basic "Authorized"; # Must have a description of the basic validation, otherwise the validation request window will not pop up. auth_basic_user_file /etc/nginx/conf.d/passwd; After reloading the page, open it again and you will see a popup reminding you to verify it.

Beautify

After the above configuration, it is almost ready, but the default index interface is not very nice.
So I found the Nginx-Fancyindex-Theme beautification template, and configured it to look like this:

It’s a little better looking.

Download

You can get the download link directly on the page, but if you download it directly out of your browser, there will be a validation failure error message, such as: ``bash curl https://drive.moonagic.com/moonagic.com_ecc.zip -o moonagic.com_ecc.zip

401 Authorization Required

401 Authorization Required


nginx/1.15.2
``bash''
wget https://drive.moonagic.com/moonagic.com_ecc.zip
--2018-08-06 21:33:48 - https://drive.moonagic.com/moonagic.com_ecc.zip
Resolving drive.moonagic.com (drive.moonagic.com)... 104.199.220.164
Connecting to drive.moonagic.com (drive.moonagic.com)|104.199.220.164|:443... Connecting.
HTTP request sent, awaiting response... 401 Unauthorized

Username/Password Authentication Failed.

This time you need to add basic authentication information manually, ``bash’’ curl [email protected]/moonagic.com_ecc.zip -o moonagic.com_ecc.zip The following table shows the percentage of the total number of participants in the programme for the biennium 2004-2005. Dload Upload Total Spent Left Speed 100 1682k 100 1682k 0 0 862k 0 0:00:01 0:00:01 —:— 862k

``bash''
wget --http-user=user --http-password=password https://drive.moonagic.com/moonagic.com_ecc.zip
--2018-08-06 21:37:41 - https://drive.moonagic.com/moonagic.com_ecc.zip
Resolving drive.moonagic.com (drive.moonagic.com)... 104.199.220.164
Connecting to drive.moonagic.com (drive.moonagic.com)|104.199.220.164|:443... Connecting.
HTTP request sent, awaiting response... 401 Unauthorized
Authentication selected: Basic realm="Authorized"
Reusing existing connection to drive.moonagic.com:443.
HTTP request sent, awaiting response... 200 OK Reusing existing connection to drive.moonagic.com:443.
Length: 1722401 (1.6M) [application/zip]
Saving to: 'moonagic.com_ecc.zip'

moonagic.com_ecc.zip.1 100%[=================================>] 1.64M --. -KB/s in 0.02s

2018-08-06 21:37:44 (79.3 MB/s) - 'moonagic.com_ecc.zip' saved [1722401/1722401]

Other

As rclone mounts on Google Drive, you may notice a significant lead time when downloading larger files, but it’s not a big deal.
In fact, there are many things you can do with rclone, such as write a simple shell script to achieve a weekly/daily/hourly backup of various configurations of Linux and so on.