Setting up a quick and dirty image host

I wanted to be able to host images on my own host that could be directly linked to without having to worry about other services. Sites like Imgur are great, except I would rather keep my images on my own host so that I can have access to them all easily. But I still wanted to use tools like ShareX to upload quickly and share images.


First off, let me explain what you’ll end up with. You end up with something like . This will be a direct link right to an image. I created this right from ShareX without having to do any manual work.

Setting up DNS

DNS is a matter of simply setting up an A record pointing to the subdomain you want to use for the record.

Here is what my Cloudflare DNS looks like for the part:


That is all you need to change for the DNS.

Apache Configuration

The apache configuration is what I’ll be showing here, if you use a different engine you’ll have to figure that out on your own. I am using Ubuntu 14.04 LTS so my apache file locations may be slightly different than yours.

I created a new file called /etc/apache/sites-available/ 

The file ended up looking like this:

<VirtualHost *:80>
    Redirect permanent /

<VirtualHost *:443>
    SSLEngine on
    SSLProtocol all -SSLv2

    SSLCertificateFile /etc/letsencrypt/live/
    SSLCertificateKeyFile /etc/letsencrypt/live/
    SSLCertificateChainFile /etc/letsencrypt/live/


    DocumentRoot /var/www/images/

    <Directory />
        Options FollowSymLinks
        AllowOverride None
    <Directory /var/www/images/>
        AuthType Basic
        AuthName "Images Directory Listing"
        AuthUserFile /etc/apache2/.htpasswd
        Require valid-user
        <Files ?*>
            Require all granted
            Satisfy any
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all

Let me explain what is going on in this file, since it looks a little big for what it is doing. The virtual host section for port 80 is simply redirecting everything to the HTTPS version of my site. I know these are just images, but I might as well serve them with HTTPS, with Let’s Encrypt there is not much reason to not use SSL.

Virtual Host changes

  • I set the “ServerName” and “ServerAlias” to be that of my subdomain. This should be the same as what I made my A record in the DNS.
  • I specify the directory my images are “/var/www/images/”.  Within this I setup basic authentication, but only on the directory itself, not the files within it. This is so that I could still have access to the directory index to see all the files, but don’t have to worry about everyone seeing this.
  • I also have the required elements for using an SSL cert setup.

Then to finish off the apache setup just run:

sudo a2ensite /etc/apache/sites-available/

This will enable the configuration. Make sure you adjust the SSL part or just use the port 80 virtualhost and don’t have SSL.


You’ll need to make sure that the directory you’re storing the images has permissions to be viewable on the web. In my case I made it own by my www-data group, and my user account is part of this group. That way there are no permission problems when uploading.

ShareX Setup

I will be showing how to setup ShareX here, however the settings are similar for most programs. It is a matter of setting up ftp/sftp in your screenshot program. In the “destination settings” I added a new FTP configuration:

ShareX Destination Settings

ShareX Destination Settings

Once the destination is set, I needed to also make sure that the selected image host to use is “FTP”:

ShareX Image Host Selection

ShareX Image Host Selection

And then to complete this I also wanted it so that a random 4 character string is used for the image name, instead of something longer. I did that in the “Task Settings” under “Upload”. I changed the name to “%ra{4}”:

ShareX name settings

ShareX name settings


And that is all! You should now all be setup! If you have any questions feel free to ask me via the comments or contact me by email.

How to use Google Chrome’s New Options v2 with your Extension Looking into the possibility of the transition from introversion to extroversion