Lighttpd - symbolic link configuration

Hello DietPi community,

I installed Aria2 with dietpi-software, everything works fine - I have access to the lighttpd server with my ip, so far so good.

I created a symbolic link from the Aria2 download folder to /var/www .

[root@DietPi:~]# ln -s /mnt/dietpi_userdata/downloads /var/www/downloads
[root@DietPi:~]# ls /var/www
apc.php  aria2  downloads  index.lighttpd.html  opcache.php  phpinfo.php

However, I don’t know what permission to give to the directorydownloads to be able to access it with <my ip>/downloads from my browser, without blocking access to the downloads in /mnt/dietpi_userdata/downloads used by Aria2 for downloads.

At the moment when I type in the address bar of my browser <my ip>/downloads I get an error message 403 Forbidden.

A little help would be appreciated - thank you all. :call_me_hand:

I think you get 403 error because there is no index.php/html in this directory and dir listening is not enabled.

You can create a new config file with the dir-listening rule, enable this config file and reload lighttpd

touch /etc/lighttpd/conf-available/99-dir-list-downloads.conf
echo '$HTTP["url"] =~ "^/downloads($|/)" { server.dir-listing = "enable" }' >> /etc/lighttpd/conf-available/99-dir-list-downloads.conf
lighty-enable-mod dir-list-downloads
service lighttpd force-reload

hello @Jappe

Thank you for your answer, so can I delete the symbolic link I made? or should I leave it? before creating this one.

No, leave the link, but I tried to recreate your config and I found an issue.
With your command ln -s /mnt/dietpi_userdata/downloads /var/www/downloads you will get a folder inside downloads like /var/www/downloads/downloads, which is maybe not what you want to achieve?
If you want the files from inside /mnt/dietpi_userdata/downloads to be shown in /var/www/downloads (like you have a file movie.mp4 inside your original downloads folder and you want to access it via /var/www/downloads/movie.mp4) you need to modify the syntax of the command, but first let’s remove the false link

rm /var/www/downloads/downloads

and create the right one

ln -s /mnt/dietpi_userdata/downloads /var/www/

Then it is important that anybody can read these files, so let’s check this with

ls -la /mnt/dietpi_userdata/downloads

@Jappe , yes …ok I’ll do that right now and come back for feedback,

thanks for your answer …


[root@DietPi:~]# touch /etc/lighttpd/conf-available/99-dir-list-downloads.conf
[root@DietPi:~]# echo '$HTTP["url"] =~ "^/downloads($|/)" { server.dir-listing = "enable" }' >> /etc/lighttpd/conf-available/99-dir-list-downloads.conf
[root@DietPi:~]# lighty-enable-mod dir-list-downloads
Enabling dir-list-downloads: ok
Run "service lighttpd force-reload" to enable changes
[root@DietPi:~]# service lighttpd force-reload
[root@DietPi:~]# rm /var/www/downloads/downloads
rm: impossible de supprimer '/var/www/downloads/downloads': Aucun fichier ou dossier de ce type
[root@DietPi:~]# ln -s /mnt/dietpi_userdata/downloads /var/www/
[root@DietPi:~]# ls -la /mnt/dietpi_userdata/downloads
total 3955048
drwxrwxr-x 2 dietpi dietpi       4096  8 déc.  16:25 .
drwxrwxr-x 7 dietpi dietpi       4096  8 déc.  08:51 ..
-rw-rw-r-- 1 aria2  dietpi          0  8 déc.  16:25 aria2.session
-rw-rw-r-- 1 aria2  dietpi 1246226056  8 déc.  09:13 coolmovie.mkv
-rw-rw-r-- 1 aria2  dietpi 1310228092  8 déc.  06:00 movie01.mkv
-rw-rw-r-- 1 aria2  dietpi  888166194  8 déc.  05:57 another_movie.mkv
-rw-rw-r-- 1 aria2  dietpi  605317719  8 déc.  15:40 some_great_movie.mkv

..all is there ..

Looks good, you should be able now to access it via <my ip>/downloads

no - 403 Forbidden ( but I didn’t reload lighttpd so maybe that’s it ? )

The command service lighttpd force-reload reloaded lighttpd.
Can you show ls -la /var/www

[root@DietPi:~]# service lighttpd force-reload
[root@DietPi:~]# ls -la /var/www
total 1304
drwxr-xr-x  3 root root   4096  8 déc.  17:02 .
drwxr-xr-x 12 root root   4096 30 nov.  20:39 ..
-rw-r--r--  1 root root  43952  8 déc.  08:50 apc.php
drwxrwxr-x  5 root root   4096  1 sept.  2021 aria2
lrwxrwxrwx  1 root root     30  8 déc.  17:02 downloads -> /mnt/dietpi_userdata/downloads
-rw-r--r--  1 root root    395  8 déc.  14:35 index.lighttpd.html
-rw-r--r--  1 root root 991709  8 déc.  13:19 iRMGD1l.gif
-rw-r--r--  1 root root 196593  8 déc.  14:27 jPjdgDQ.jpg
-rw-r--r--  1 root root  76158  8 déc.  08:50 opcache.php
-rw-r--r--  1 root root     20  8 déc.  08:50 phpinfo.php

403 Forbidden after service lighttpd force-reload

/mnt/dietpi_userdata/downloads is readable, also /var/downloads.
The module mod_dirlisting is loaded by default and don’t has to be activated in any config.

Let’s make sure the content of the created config is right:
cat /etc/lighttpd/conf-available/99-dir-list-downloads.conf

Yeeeep ! - after a restart I have access to the page downloads - I’m just doing a test download withAria2 …- I’ll be right back for feedback … I think we’re good. … I’ll be back. :call_me_hand:

1 Like

Did you restart lighttpd or the whole device?
In my test it was working just with service lighttpd force-reload :person_shrugging:

so :

  • Aria2 can download
    -Index of /downloads/
    is accessible and readable from my browser (I’ll look later if the stream or DL doesn’t work),
    -possible to hide : Screenshot by Lightshot ( the Aria2.session ?

I have restart the device … after the last command : service lighttpd force-reload

For this you can add a line to the created config file:

dir-listing.exclude  = ( "aria2.session" )

In this one … /etc/lighttpd/conf-available/99-dir-list-downloads.conf - that’s right ?

|edit |- All work like a charm —

a orera’ te pia toetoe’ - mauruuru roa’ :call_me_hand:

1 Like

Btw, we use systemd, so the native command is:

systemctl restart lighttpd
1 Like

@MichaIng , yess ok - thank you for the clarification :wink: