Info Security Memo
  • Blog
  • Sitemap
    • Categories
  • Contact
  • About
  • Resources
  • Tools
  • 51sec.org

Build Confidence

Focusing on Information Security 

Info Security Notes

Deploy Aria2 Docker To Downdload to Cloud Drives (Google Drive One Drive etc)

10/8/2022

0 Comments

 
Deploy Aria2 Docker To Downdload to Cloud Drives (Google Drive, One Drive etc)

One thing you can use your Cloud VPS to do is to set up downloading site for yourself. My previous posts have showed a way you can create your own downloading site to integrate with your cloud drivers using Aria2, AriaNG, Rclone, FileBrowser, etc. 

  • Build Cloud Download Site Using One Docker (FileBrowser+Aria2+AriaNg+Rclone+Caddy)
  • Use Aria2 docker+ariang to download and Rclone to Mount Google Drive and Sync

There are lots of components to achieve that purpose in those posts, although it is already simplified by using one docker to host all application services. To make it simpler, I found another Github project to achieve this same purpose, but the process is much simpler. Please find out all related steps below and let me know if there is any question. 


Diagram




Pre-requisites

In this lab, I am using Ubuntu 20.04 VM in Oracle Cloud Free tier as an example. All following commands are based on this Ubuntu 20.04 version Oracle Cloud platform. Please adjust it accordingly if you are using different system or platform. 

For more details about docker, Portainer, NPM configuration, please check following posts:
  1. Deploy Docker, Docker-Compose, Portainer and NPM (Nginx Proxy Manager)
  2. Run Free Arm-based Oracle Linux (Install Docker/Docker Compose/Portainer/Ubuntu Virtual Desktop)
  3. Install Docker, Docker-Compose, Portainer & Nginx on CentOS 8 & Ubuntu 20.04
Commands list after run "sudo -i":
System update:
apt update -y && apt upgrade -y
Increase SWAP size to at least 1024MB

wget https://raw.githubusercontent.com/51sec/swap/main/swap.sh && bash swap.sh


Install Docker and Docker-Compose:

apt install docker.io -y 
apt install docker-compose -y 


Install Portainer (Optional):

docker volume create portainer_data

docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

Install NPM (Nginx Proxy Manager) (Optional)

docker run -d -p 80:80 -p 81:81 -p 443:443 --name npm --restart unless-stopped -v ./letsencrypt:/etc/letsencrypt -v ./data:/data  jc21/nginx-proxy-manager:latest


Firewall Ports 

It is important for the firewall to open follwoing ports:
  • tcp 9000 - Portainer (Optional)
  • tcp 80 - NPM (Optional)
  • tcp 443 - NPM (Optional)
  • tcp 81 - NPM (Optional)
  • tcp 6800 - RPC port for AriaNG to connect
  • tcp/udp 6888 - BT port
  • tcp 6880 - AriaNG port

Create Folder Structure 


sudo -i
mkdir aria2-config
mkdir aria2-downloads



Deploy Aria2-Pro Docker

Related Sites:

  • GitHub: https://github.com/P3TERX/docker-aria2-pro
  • Docker Hub: https://hub.docker.com/r/p3terx/aria2-pro
  • Related Post: https://p3terx.com/archives/docker-aria2-pro.html

Simple command to run. Only thing to do is to set up RPC_SECRET Token:

docker run -d \
    --name aria2-pro \
    --restart unless-stopped \
    --log-opt max-size=1m \
    -e PUID=$UID \
    -e PGID=$GID \
    -e UMASK_SET=022 \
    -e RPC_SECRET=<Token> \
    -e RPC_PORT=6800 \
    -p 6800:6800 \
    -e LISTEN_PORT=6888 \
    -p 6888:6888 \
    -p 6888:6888/udp \
    -v $PWD/aria2-config:/config \
    -v $PWD/aria2-downloads:/downloads \
    -e SPECIAL_MODE=rclone \
    p3terx/aria2-pro

Configure Rclone connecting to your Cloud Drives



docker exec -it aria2-pro rclone config




Croot@ubuntu-docker-1:~# docker exec -it aria2-pro rclone config
Current remotes:
Name                 Type
====                 ====
gd                   drive
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> e
Select remote.
Choose a number from below, or type in an existing value.
 1 > gd
remote>
This value is required and it has no default.
remote> 1
Editing existing "gd" remote with options:
- type: drive
- client_id: 84976948510-dd3808r8omub1bum92uan52hdhg6pjsu.apps.googleusercontent.com
- client_secret: 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
- scope: drive
Option client_id.
Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a string value. Press Enter for the default (84976948510-dd3808r8omub1bum92uan52hdhg6pjsu.apps.googleusercontent.com).
client_id> 84976948510-dd3808r8omub1bum92uan52hdhg6pjsu.apps.googleusercontent.com
Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a string value. Press Enter for the default (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).
client_secret> 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
Option scope.
Scope that rclone should use when requesting access from drive.
Choose a number from below, or type in your own string value.
Press Enter for the default (drive).
 1 / Full access all files, excluding Application Data Folder.
   \ (drive)
 2 / Read-only access to file metadata and file contents.
   \ (drive.readonly)
   / Access to files created by rclone only.
 3 | These are visible in the drive website.
   | File authorization is revoked when the user deauthorizes the app.
   \ (drive.file)
   / Allows read and write access to the Application Data folder.
 4 | This is not visible in the drive website.
   \ (drive.appfolder)
   / Allows read-only access to file metadata but
 5 | does not allow any access to read or download file content.
   \ (drive.metadata.readonly)
scope> 1
Option service_account_file.
Service Account Credentials JSON file path.
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.
Enter a value. Press Enter to leave empty.
service_account_file>
Edit advanced config?
y) Yes
n) No (default)
y/n>
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine
y) Yes (default)
n) No
y/n> n
Option config_token.
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
        rclone authorize "drive" "eyJjbGllbnRfaWQiOiI4NDk3Njk0ODUxMC1kZDM4MDhyOG9tdWIxYnVtOTJ1YW41MmhkaGc2cGpzdS5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsImNsaWVudF9zZWNyZXQiOiJHT0NTUFgtNkpnRTRzN09VR2RyX25LYW0tQU5KGE5eHZMMSIsInNjb3BlIjoiZHJpdmUifQ"
Then paste the result.
Enter a value.
config_token> eyJ0b2tlbiI6IntcImFjY2Vzc190b2tlblwiOlwieWEyOS5hMEFhNHhyWE9Jc2t2V0lSQkQ3NmFIMGpBNEdwN0REMlRBT1pEbVhsRXFINFV5YkRsS1dpeHI0LUhkN1d6WTg3YnVORHZaQ2I0OUo3bV9ibm1DT0JoeXRXSFZoMVBwdExNY1N6elZTVUZoWFNaczFucWNXYTVlSUlZbUF1SkZ5TDJBUkNWLXFCYlZKeTB0N3dEdlF6eG53TXZVYkxuSmFDZ1lLQVRBU0FSSVNGUUVqRHZMOVNodVg5ZFdtSFJ2NU5wYUZiTkxmZGcwMTYzXCIsXCJ0b2tlbl90eXBlXCI6XCJCZWFyZXJcIixcInJlZnJlc2hfdG9rZW5cIjpcIjEvLzA0TDB2V2VQU2xHVDBDZ1lJQVJBQUdBUVNOd0YtTDlJckMwNC1vSWRvZlVaODVwTVBnbnZQWjR3WVdFemZMLXFsamVDV2xmMG9rZnk2bk9aY3FnSUVKbUtUc0htRE4yVlgzejBcIixcImV4cGlyeVwiOlwiMjAyMi0xMC0wMVQxNjowMToxOC41NjI3NDQ1MjcrMDI6MDcIn0ifQ
Configure this as a Shared Drive (Team Drive)?
y) Yes
n) No (default)
y/n> y^H^H^[[D^[[D^[[D
This value must be a single character, one of the following: y, n.
y/n> y
Option config_team_drive.
Shared Drive
Choose a number from below, or type in your own string value.
Press Enter for the default (0AEZdJ516op5fUk9PVA).
 1 / Private
   \ (0AEZdJ516op5fUk9PVA)
config_team_drive>
Configuration complete.
Options:
- type: drive
- client_id: 84976948510-dd3808r8omub1bum92uan52hdhg6pjsu.apps.googleusercontent.com
- client_secret: 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
- scope: drive
- token: {"access_token":"ya29.a0Aa4xrXOIskvWIRBD76aH0jA4Gp7DD2TAOZDmXlEqH4UybDlKWixr4-Hd7WzY87buNDvZCb49J7m_bnmCOBhytWHVh1PptLMcSzzVSUFhXSZs1nqcWa5eIIYmAuJFyL2ARCV-qBbVJy0t7wDvQzxnwMvUbLnJaCgYKATASARISFQEjDvL9ShuX9dWmHRv5NpaFbNLfdg0163","token_type":"Bearer","refresh_token":"1//04L0vWePSlGT0CgYIARAAGAQSNwF-L9IrC04-oIdofUZ85pMPgnvPZ4wYWEzfL-qljeCWlf0okfy6nOZcqgIEJmKTsHmDN2VX3z0","expiry":"2022-10-01T16:01:18.562744527+02:00"}
- team_drive: 0AEZdJ516op5fUk9PVA
- root_folder_id:
Keep this "gd" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:
Name                 Type
====                 ====
gd                   drive
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q>






Deploy AriaNG (Optional)


Then you need a WebUI for control, such as AriaNg. This link is provided by the developer and can be used directly. Or use Docker to deploy it yourself:

docker run -d \
    --name ariang \
    --log-opt max-size=1m \
    --restart unless-stopped \
    -p 6880:6880 \
    p3terx/ariang




Maintenance

Reboot:
  • docker restart aria2-pro

Re-deploy: 

  • docker rm -f aria2-pro
  • docker rmi p3terx/aria2-pro
  • rm -rf ~/aria2-config
  • docker pull p3terx/aria2-pro
  • docker run <...>

Check Logs
  • Realtime logs:
    • docker logs -f --tail 30 aria2-pro
  • Export logs
    • docker logs aria2-pro > ~/aria2-pro.log



References

  • Aria2 Pro - 更好用的 Aria2 Docker 容器镜像
  • https://hub.docker.com/r/p3terx/aria2-pro
  • https://github.com/P3TERX/Aria2-Pro-Docker
  • https://github.com/wahyd4/aria2-ariang-docker/

via Blogger http://blog.51sec.org/2022/10/deploy-aria2-docker-to-downdload-to.html
October 08, 2022 at 08:03PM Docker
0 Comments



Leave a Reply.

    Categories

    All
    Architecture
    Blog
    Checkpoint
    Cisco
    Cloud
    CyberArk
    F5
    Fortigate
    Guardium
    Juniper
    Linux
    Network
    Others
    Palo Alto
    Qualys
    Raspberry Pi
    Security
    SIEM
    Software
    Vmware
    VPN
    Wireless

    Archives

    March 2024
    February 2024
    January 2024
    December 2023
    November 2023
    October 2023
    September 2023
    August 2023
    July 2023
    June 2023
    May 2023
    April 2023
    March 2023
    February 2023
    January 2023
    December 2022
    November 2022
    October 2022
    September 2022
    August 2022
    July 2022
    June 2022
    May 2022
    April 2022
    March 2022
    February 2022
    January 2022
    December 2021
    November 2021
    October 2021
    September 2021
    August 2021
    July 2021
    June 2021
    May 2021
    April 2021
    March 2021
    February 2021
    January 2021
    December 2020
    November 2020
    October 2020
    September 2020
    August 2020
    July 2020
    October 2019
    September 2019
    June 2019
    July 2018
    May 2018
    December 2017
    August 2017
    April 2017
    March 2017
    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016
    December 2015
    November 2015
    October 2015
    September 2015
    August 2015
    July 2015
    June 2015
    May 2015
    April 2015
    March 2015

    Print Page:

    RSS Feed

    Email Subscribe
Powered by Create your own unique website with customizable templates.
  • Blog
  • Sitemap
    • Categories
  • Contact
  • About
  • Resources
  • Tools
  • 51sec.org