Commands.page Logo

How to Set Custom Referer Header in aria2c on Ubuntu

This guide explains how to configure a custom referer header for HTTP requests when using aria2c on Ubuntu. You will learn the command-line flags and configuration file options needed to modify request headers, ensuring successful downloads from servers that validate referer information.

Using the Command Line

The most direct method is adding the --referer flag to your aria2c command. This sets the Referer header for the specific download session.

aria2c --referer="https://example.com" "https://example.com/file.zip"

Replace https://example.com with the URL you need to mimic as the referring page.

Using the Configuration File

For permanent settings, edit the aria2 configuration file located at ~/.config/aria2/aria2.conf. If the file does not exist, create it. Add the following line:

referer=https://example.com

Save the file and restart any running aria2c daemon instances for changes to take effect.

Using an Input File

If you are downloading multiple links from a text file, you can specify options alongside each URL. Create a file named downloads.txt and format it as follows:

--referer=https://example.com
https://example.com/file1.zip

--referer=https://another-site.com
https://another-site.com/file2.zip

Run aria2c with the input file option:

aria2c -i downloads.txt

Verifying the Header

To confirm the header is being sent, you can use a test endpoint that echoes headers or inspect network traffic using tools like Wireshark or tcpdump on Ubuntu. This ensures the server receives the correct referer information required for access.