Skip to content

Instantly share code, notes, and snippets.

@maple3142
Last active September 26, 2023 07:38
Show Gist options
  • Save maple3142/295a9beb982f03bf1fb2bc3b78a75250 to your computer and use it in GitHub Desktop.
Save maple3142/295a9beb982f03bf1fb2bc3b78a75250 to your computer and use it in GitHub Desktop.
# Put this file in /etc/nginx/sites-available
# Then "ln -s /etc/nginx/sites-available/aria2-nginx.conf /etc/nginx/sites-enabled"
# Then "sudo service nginx restart"
server {
listen 80;
listen [::]:80;
root /var/www/aria2; # Put your aria2 web ui here, such as AriaNg
index index.html;
server_name DOMAIN_NAME;
location / {
try_files $uri $uri/ =404;
}
location /jsonrpc {
# Proxy jsonrpc to local aria2c server, since https page can't make "http" and "ws" connection.
# To connect, simply connect to wss://DOMAIN_NAME:443/jsonrpc
proxy_pass http://localhost:6800/jsonrpc;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /files {
alias /home/USER/downloads; # Aria2c download folder
autoindex on;
}
# Remember to use "sudo certbot --nginx" to enable ssl
}
# Secret
rpc-secret=SECRET
enable-rpc=true
# Only allow connection from nginx proxy
rpc-allow-origin-all=false
rpc-listen-all=false
max-concurrent-downloads=5
continue=true
max-connection-per-server=16
min-split-size=10M
split=10
max-overall-download-limit=0
max-download-limit=0
max-overall-upload-limit=0
max-upload-limit=0
# Download destination, should be the same in "/files" block of nginx config
dir=/home/user/downloads
# Your session file location, and you shouldn't forget to create it before hand. (Or aria2c will fail to start.)
input-file=/home/user/.aria2.session
save-session=/home/user/.aria2.session
file-allocation=prealloc
referer=*
http-accept-gzip=true
save-session-interval=60
force-save=false
log-level=notice
# Log file
log=/home/user/.aria2.log
allow-overwrite=true
# BT seeding configurations, modify it dependes on your needs and server bandwidth
seed-time=0
seed-ratio=0
# Put this file in "/etc/systemd/system" to make it a systemd service
# "sudo service aria2c start" to start
[Unit]
Description=Aria2c download manager
After=network.target
[Service]
Type=simple
User=user # Your username
ExecStart=/usr/bin/aria2c --conf-path=/home/user/aria2.conf # Modify your configuration location here
[Install]
WantedBy=multi-user.target
@melroy89
Copy link

I think the Nginx /jsonrpc location can be just: proxy_pass http://localhost:6800;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment