Commands.page Logo

How to Set Proxy Server for aria2c on Ubuntu Linux

This guide explains how to configure a proxy server for aria2c downloads on Ubuntu. You will learn how to use command-line options, set environment variables, and modify configuration files to route your traffic through HTTP, HTTPS, or SOCKS proxies securely and efficiently.

Using Command-Line Arguments

The quickest way to specify a proxy for a single download session is by using the --all-proxy flag directly in the terminal. This method does not require changing any system settings or configuration files.

Run the following command, replacing the IP address and port with your proxy details:

aria2c --all-proxy=http://192.168.1.1:8080 "http://example.com/file.zip"

If your proxy requires authentication, include the username and password using the --all-proxy-user and --all-proxy-passwd options:

aria2c --all-proxy=http://192.168.1.1:8080 --all-proxy-user=username --all-proxy-passwd=password "http://example.com/file.zip"

Using Environment Variables

You can set proxy environment variables in your Ubuntu terminal session before running aria2c. This applies to the current terminal session only.

Export the HTTP and HTTPS proxy variables:

export http_proxy=http://192.168.1.1:8080
export https_proxy=http://192.168.1.1:8080

Once exported, run your standard aria2c command without additional proxy flags:

aria2c "http://example.com/file.zip"

Configuring the aria2.conf File

For a permanent solution, add proxy settings to your aria2 configuration file. This ensures all downloads use the proxy by default without needing extra flags.

Open or create the configuration file located at ~/.aria2/aria2.conf:

nano ~/.aria2/aria2.conf

Add the following lines to the file:

all-proxy=http://192.168.1.1:8080
all-proxy-user=username
all-proxy-passwd=password

Save the file and exit. Future aria2c downloads will automatically route through the specified proxy server.

Verifying Proxy Usage

To confirm that aria2c is using the proxy, you can check the download logs or monitor network traffic. When starting a download, aria2c will display connection details in the terminal. If the proxy is configured correctly, the connection will establish through the proxy IP address rather than your direct public IP.

For advanced verification, use a network monitoring tool like tcpdump or check the access logs on your proxy server to confirm incoming requests from your Ubuntu machine.