菜单

Aria2搭建指南(基于Ubuntu22.04)

duckflew
发布于 2023-11-28 / 145 阅读
0
0

Aria2搭建指南(基于Ubuntu22.04)

搭建Aria2离线下载服务(基于Ubuntu22.04)

1.docker-compose文件

参数参考: https://hub.docker.com/r/p3terx/aria2-pro

这里需要注意的地方有

  • 默认配置比较齐全主要是秘钥和默认下载位置 我这里只修改RPC_SECRET参数 设置一个秘钥用于连接使用
  • AriaNg是一个静态网站面板
  • host模式下的容器不需要做端口映射,如果采用桥接网络模式 则需要建立一个Docker网络,采用容器服务名进行访问
version: "3.8"
services:
  Aria2-Pro:
    container_name: aria2-pro
    image: p3terx/aria2-pro
    environment:
      - PUID=65534
      - PGID=65534
      - UMASK_SET=022
      - RPC_SECRET=xxxxxxxxxxxx
      - RPC_PORT=6800
      - LISTEN_PORT=6888
      - DISK_CACHE=64M
      - IPV6_MODE=false
      - UPDATE_TRACKERS=true
      - CUSTOM_TRACKER_URL=
      - TZ=Asia/Shanghai
    volumes:
      - ${PWD}/aria2-config:/config
      - ${PWD}/aria2-downloads:/downloads
# If you use host network mode, then no port mapping is required.
# This is the easiest way to use IPv6 networks.
    network_mode: host
#    network_mode: bridge
#    ports:
#      - 6800:6800
#      - 6888:6888
#      - 6888:6888/udp
    restart: unless-stopped
# Since Aria2 will continue to generate logs, limit the log size to 1M to prevent your hard disk from running out of space.
    logging:
      driver: json-file
      options:
        max-size: 1m

# AriaNg is just a static web page, usually you only need to deploy on a single host.
  AriaNg:
    container_name: ariang
    image: p3terx/ariang
    command: --port 6880 --ipv6
    network_mode: host
#    network_mode: bridge
#    ports:
#      - 6880:6880
    restart: unless-stopped
    logging:
      driver: json-file
      options:
        max-size: 1m

然后运行如下命令启动容器

docker-compose up -d

2.申请域名证书

sudo certbot certonly --standalone --preferred-challenges http -d  yourdomain.com

3.配置Nginx反向代理以及HTTPS

server {
   listen 80;
   server_name ${yourdomain.com};
   return 301 https://$host$request_uri;
}
server {
    listen 443;
    server_name yourdomain.com;
    ssl on;
    ssl_certificate /etc/letsencrypt/live/${yourdomain.com}/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/${yourdomain.com}/privkey.pem;
     location / {
            proxy_pass http://127.0.0.1:6880/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            # rewrite ^/qbit/(.*)$ /$1 break;
    }
     location /jsonrpc {
        proxy_pass http://127.0.0.1:6800;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

4.Aria2Ng面板配置

这里有几个点

  • 如果做反向代理 协议选择http,端口选择6800
  • 秘钥需要填写

评论