Can aria2 use different proxies for HTTP and FTP?
aria2 does not natively support assigning different
proxy servers to the HTTP and FTP protocols simultaneously through its
standard configuration options. While it allows you to define distinct
proxy environmental variables or command-line flags for each protocol,
aria2 handles proxy settings globally during a execution session,
meaning the last defined proxy or the catch-all
---all-proxy setting typically overrides and standardizes
the proxy backend for all concurrent downloads. To achieve simultaneous
protocol-specific proxying, users must run separate aria2 instances or
utilize a local proxy router like Privoxy.
The Limitations of aria2’s Proxy Architecture
When configuring aria2, you generally rely on specific input parameters or environment variables to route your traffic. The application recognizes the following proxy flags:
--http-proxy(orhttp_proxyenvironment variable)--ftp-proxy(orftp_proxyenvironment variable)--all-proxy(orall_proxyenvironment variable)
In theory, these flags suggest independent routing. In practice,
however, aria2’s internal download engine initializes a single network
subsystem per session. When you attempt to pass both an HTTP proxy and
an FTP proxy to a single aria2c command, the program
struggles to split the traffic concurrently across different proxy
protocols (such as SOCKS5 for one and HTTP Connect for another).
Instead, it will either default to the all-proxy setting or
apply the premier proxy configuration to all outgoing requests in that
queue, leading to connection failures on the mismatched protocol.
Workarounds for Simultaneous Multi-Proxy Downloading
If your workflow absolutely requires downloading HTTP and FTP links at the same time using different proxies, you can bypass this limitation using two primary methods.
1. Running Dual aria2 Instances
The simplest approach is to isolate your download queues by launching two separate processes of aria2. You can dedicate one instance to your HTTP traffic and the other to your FTP traffic, defining the respective proxy for each.
# Instance 1: Dedicated to HTTP downloads
aria2c --http-proxy="http://proxy1.local:8080" http://example.com/file.zip
# Instance 2: Dedicated to FTP downloads
aria2c --ftp-proxy="http://proxy2.local:8080" ftp://example.com/file.tar.gz2. Utilizing a Loopback Proxy Router
For a more integrated solution, you can route aria2 through a local proxy forwarding service like Privoxy or Squid.
In this setup, you configure aria2 to point all traffic to your local
Privoxy instance (127.0.0.1:8118) using the
--all-proxy flag. You then configure Privoxy’s routing
rules to inspect the destination URL scheme. Privoxy can seamlessly
forward all incoming HTTP requests to your HTTP proxy and all FTP
requests to your FTP proxy, handling the simultaneous protocol split
externally.