Are you tired of your images being deleted for unreasonable and/or vague reasons? Do you want a single place to put all your gens?
If yes, you should look into self-hosting your own website!
But wait. You don't want to deal with hosters nagging you over fictional content, or doxxing yourself by hosting from a home PC. Or worse yet, what if in the future they pass a law making sharing 'obscene content' over the Internet illegal? Is there a solution?
Yes! Hidden services allow you to run a website on any machine you own without revealing who or where you are (assuming you don't fuck it up or tell anyone). They also don't need you to go through the hassle of securing a domain name and SSL certificates.
This is a guide on how to set up an image gallery website hosted as a hidden service on a machine running some form of Debian (such as a Raspberry Pi).
I have a very similar site here which I recently updated to be an actual gallery: http://busahou7shinmu4ty2exfbtbdloyvebr2c7a7jmjl2d52bsxbcatqdad.onion/
This is not meant as something to organize your image collection, but as a place to share your own creations without having to jump through others' hoops.
If you just want to organize stuff you've downloaded for yourself, check out Hydrus.
Please use this knowledge for good and don't break any laws.
STEP 1: INSTALLATION
I will assume you already have Debian installed.
Open a terminal and run this command to update and install needed packages:
sudo apt update && sudo apt full-upgrade && sudo apt install llgal tor
If lots of packages get upgraded, you should restart.
STEP 2: SETTING UP A WEB SERVER
I like to keep it simple since llgal is a static site generator.
Make a directory for your images and enter it:
mkdir ~/gallery && cd ~/gallery
Put your images in this folder. Note you can use any folder!
Running the following command will run a web server in the current directory. No permissions bullshit necessary!
python3 -m http.server -b 127.0.0.1 8080
If there is no HTML in the folder, it will show a directory listing.
Visit http://127.0.0.1:8080 to see it. Note that this URL is only accessible from the device it is running on!
Keep this command running! If you're really new to Linux, pressing ctrl+C usually stops a terminal command.
STEP 3: SETTING UP llgal
Technically you don't NEED to do anything to set up llgal. Hopping into a directory with images and running 'llgal' will generate HTML and CSS for a gallery.
But the default options are kind of lackluster. Here's what I recommend.
Run this to make copies of skeleton files that llgal uses which can be easily edited.
mkdir ~/.llgal && cp /usr/share/llgal/llgal.css ~/.llgal/ && zcat /usr/share/doc/llgal/llgalrc.gz > ~/.llgal/llgalrc
Open ~/.llgal/llgal.css in whatever text editor. Here are some changes I suggest:
- Scroll down to the section 'table.index td.text-thumb', and change font-size to 100%
- Scroll down to the section 'table.index td.thumb-dim', and change font-size to 100%
- Scroll down to the section 'table.slide td.image-slide img' and add the following lines (makes images in slides fit on the screen horizontally, maintaining aspect ratio)
max-width: 90vw; width: auto; height: auto;
Next open ~/.llgal/llgalrc and take a look around. Suggested changes (remove # from the start of a line to activate it):
thumbnails_dimensions_from_css = 1 thumbnail_height_max = 240 thumbnail_width_max = 240 slide_dimensions_from_css = 1
The above mostly make the CSS actually work.
show_dimensions = 1 show_size = 1
These show the image's size and dimensions on the gallery page.
index_title_default = "whatever you want" thumbnail_create_command = "convert -scale <MAXW>x<MAXH> -- <IN> JPG:<OUT>"
This forces thumbnails to be JPG. It breaks if used on GIF files, but lowers load times if the source images are PNGs.
sort_criteria = "revtime"
This shows newest images first.
Sort criteria has a few options:
- name: alphabetical, case sensitive
- iname: alphabetical, case insensitive
- size: file size
- time: modified time
- none
All but none can be reversed by adding rev to the beginning (revname, revtime, etc).
Note that 'slide' pages are not permanent and when you run llgal again they're likely to shift around. Image URLs don't change as llgal doesn't actually modify or move any images.
For a deep explanation on how everything in llgal works, check out the manual:
man llgal
To update your site, just run 'llgal' from the directory the images are in and it will generate the thumbnails and HTML.
OPTIONAL STEP: generating vanity onion URL
If you skip this, your hidden service's URL will be complete gibberish. It'll work fine, but you might want it to look like your username or something.
I recommend skipping this step if you want more than 7 characters. For each additional character it becomes exponentially harder to find a URL.
For example, finding a URL starting with 'busahou' would take my PC an average of 15 minutes.
Finding specifically busahoux would take an average of 8 days; busahouxy would take eight and a half months.
Also note that the characters 0, 1, 8, and 9 are not possible in an onion address.
If you do want to do this, install these dependencies:
sudo apt install gcc libc6-dev libsodium-dev make autoconf
Then download https://github.com/cathugger/mkp224o/releases/download/v1.7.0/mkp224o-1.7.0-src.tar.gz
Extract and enter the folder:
tar xf mkp224o-1.7.0-src.tar.gz && cd mkp224o
Build it:
./autogen.sh && ./configure && make
Then start searching for keys:
./mkp224o -B -d keys [your prefix here]
Again, Ctrl+C to stop. It searches random keys so there is no 'progress' and you can start and stop as you wish.
Found keys are put in the 'keys' folder. We will use these later.
To calculate the AVERAGE amount of time it would take to generate a key, use this formula:
32^[number of characters]/[hashes per second] = average number of SECONDS per key found
STEP 4: SETTING UP tor
Run the following to start the Tor service, and automatically start it at boot:
systemctl enable --now tor
This will generate some files we need.
Then run this command:
sudoedit /etc/tor/torrc
This is the configuration file for Tor. Scroll down until you see a line that starts like "############### This section is just for location-hidden services ###"
Add two lines like this:
HiddenServiceDir /var/lib/tor/[HIDDEN SERVICE NAME HERE]/ HiddenServicePort 80 127.0.0.1:8080
Note the 8080! This is telling Tor to look at the server we just set up and serve it through the hidden service's port 80 (HTTP traffic).
The name doesn't really matter, it's just for organizing if you have multiple.
Now restart the tor service:
sudo systemctl restart tor
The hidden service is now up and serving your website (assuming you're still running the web server command from earlier).
Run this command to get the address:
sudo cat /var/lib/tor/[HIDDEN SERVICE NAME HERE]/hostname
Paste that into the Tor browser and it should connect in a few seconds.
But wait, what if you want the vanity address you generated earlier?
In that case, just run this command:
sudo cp /path/to/vanity.onion/* /var/lib/tor/[HIDDEN SERVICE NAME HERE]/ && sudo systemctl restart tor
Basically all you need to do is move the three files from the folder mkp224o generated to the hidden service's folder and restart tor.
THE END!
Some potential questions that might come up.
Q. Isn't HTTP insecure?
If we weren't using Tor, yes. But in our case it doesn't matter as Tor hides the content of the stuff you're looking at from anyone else but you.
Q. Isn't Tor slow?
Yes, but it's not as bad as you might think. If you think it's too slow, look into optimizing your images and/or using smaller thumbnails.
Q. These explanations suck, I can't figure out how to do X!
I can try to help if you explain what goes wrong in a comment.
Q. Your site looks different from mine after I followed this guide!
I just went over a basic single-folder setup of llgal. If you want subfolder galleries, start reading the manual and experimenting!
Q. How will people find my site?
You have to tell them! Search engines don't really catalogue hidden services, and the ones that do are usually told about them by their owners or users.
Updated