How to install YOURLS and reverse proxy it using linuxserver letsencrypt/swag on Unraid

What is YOURLS

YOURLS stands for Your Own URL Shortener. It is a small set of PHP scripts that will allow you to run your own URL shortening service (a la TinyURL or Bitly).
Running your own URL shortener is fun, geeky and useful: you own your data and don’t depend on third-party services. It’s also a great way to add branding to your short URLs, instead of using the same public URL shortener everyone uses.

MariaDB Installation

Installing MariaDB is very straight forward. Go to the “Apps” tab and search for mariadb and click install.  If you already have mariadb installed and are using it with another application you can scroll down to the Create the yourls database manually part.

  1. Choose your host port and your MYSQL Root password.
  2. Add the database name variable. MYSQL_DATABASE
  3. Add the database user variable. MYSQL_USER
  4. Add the user password variable. MYSQL_PASSWORD

Optional: Create the yourls database manually

  1. Open terminal and exec into the container with docker exec -it mariadb bashor use the console shortcut on the Dashboard page.
  2. Log into mysql with user root and the password you chose. mysql -uroot -p enter your password.

The output will look like this:

[email protected]:~# docker exec -it mariadb bash
[email protected]:/# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.1.30-MariaDB-1~xenial binary distribution

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]

Next up is creating the database. (Remember to end all queries with a semicolon)

  1. Start with creating a user for the database. CREATE USER 'user' IDENTIFIED by 'password'; Where ‘user’ is your username and ‘password’ is the password you want for the new user. The ouput will be like this.
    MariaDB [(none)]> CREATE USER 'gilbn' IDENTIFIED by 'myuserpassword';
    Query OK, 0 rows affected (0.01 sec)
  2. Create the database with CREATE DATABASE IF NOT EXISTS yourls;
    MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS yourls;
    Query OK, 1 row affected (0.00 sec)
  3. Give the user permissions to the database with GRANT ALL PRIVILEGES ON yourls.* TO 'gilbn' IDENTIFIED BY 'mypassword';
    MariaDB [(none)]> GRANT ALL PRIVILEGES ON yourls.* TO 'gilbn' IDENTIFIED BY 'myuserpassword';
    Query OK, 0 rows affected (0.00 sec)

Then quit mysql with quit and exit from the container by issuing the command exit



If you already have swag setup you can just skip down to the nginx part.
Go to the “Apps” tab and search for swag and install the linuxserver swag container.

I strongly recommend reading this excellent guide by aptalca

Forward your domain to your public IP address. After you’ve done that add your different ANAME/CNAME records e.g

  1. Container Port: 80 – Choose your desired host port. e.g 81 (You can’t set this to 80 as the unRAID web GUI uses that. )
  2. Container Port: 443 – Set this to 444 or something else (On update 6.4 unraid will use port 443 and it’s better to be ahead of time so it won’t cause any issues)
  3. Enter you email
  4. Add you domain e.g
  5. Add your different sub domains e.g www,blog,yourls ect
  6. Container Path: /config Install the container config to your desired location.

Next is portforwarding. This is done on your router and you need to forward port 80 to the port you chose in step 1. You also need to forward port 443 to 444 or the one you chose. So if your servers ip is and you have chosen that the container is on port 81, you need to forward all traffic on port 80 to port 81 on ip And do the same for port 443.
If you’re unsure how to do this on your router check out: Next go to https://yourserverip:444 or http://yourserverip:81 If you now see the Nginx welcome page, it works. Also test if redirects you to the nginx welcome page.

[eckosc_quote quote=”Note: TTL differs from each provider, some has a minimum 60 minutes before DNS propagates and others have 1 minute. So it might take a while before works.” source=”” url=”” pull=”false”] If you already have swag setup and working with a domain and want to use another domain for your wordpress site you can do that by using the EXTRA_DOMAINS variable.

  1. Click on + Add another Path, Port or Variable
  2. Add these values. Config Type: Variable Name: Extra domain Key: EXTRA_DOMAINS Value:,


Go to the swag appdata location. Find the nginx folder and then create a new yourls.conf file in the “site-conf” folder. I recommend using notepad++ if you are editing the files on a windows machine.

If you want to Geo block your site read more here

Add the following in the conf file and save:

server {
    listen 80;
    return 301 https://$server_name$request_uri;
server {    
    listen 443 ssl http2;

    #SSL settings
    include /config/nginx/ssl.conf;
    root /config/www/YOURLS;
    index index.php index.html index.htm;
    # PHP
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # With php7-cgi alone:
        # With php7-fpm:
        #fastcgi_pass unix:/var/run/php7-fpm.sock;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
  location / {
    try_files $uri $uri/ /yourls-loader.php$is_args$args;

Installing YOURLS

Go to and download the latest version and  create a folder called YOURLS in the /www folder in your swag appdata location. Extract the contents in the folder.
You can also use git to clone the repo into the /www folder.
Note: You can install Git using the Nerd Tools plugin.

cd to your /www folder and run git clone

[email protected]:/mnt/user/Docker/letsencrypt/www# git clone
Cloning into 'YOURLS'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 11082 (delta 0), reused 3 (delta 0), pack-reused 11078
Receiving objects: 100% (11082/11082), 15.33 MiB | 12.88 MiB/s, done.
Resolving deltas: 100% (6752/6752), done.

Go to the YOURLS folder and copy user/config-sample.php to user/config.php
Open user/config.php  and fill in the required settings.

It should look like something like this:

/** MySQL database username */
define( 'YOURLS_DB_USER', 'yourls' );

/** MySQL database password */
define( 'YOURLS_DB_PASS', 'myuserpassword' );

/** The name of the database for YOURLS */
define( 'YOURLS_DB_NAME', 'yourls' );

/** MySQL hostname.
 ** If using a non standard port, specify it like 'hostname:port', eg. 'localhost:9999' or '' */
define( 'YOURLS_DB_HOST', '' );

/** MySQL tables prefix */
define( 'YOURLS_DB_PREFIX', 'yourls_' );

 ** Site options

/** YOURLS installation URL -- all lowercase, no trailing slash at the end.
 ** If you define it to "http://sho.rt", don't use "http://www.sho.rt" in your browser (and vice-versa) */
define( 'YOURLS_SITE', '' );

/** Server timezone GMT offset */
define( 'YOURLS_HOURS_OFFSET', 0 ); 

/** YOURLS language
 ** Change this setting to use a translation file for your language, instead of the default English.
 ** That translation file (a .mo file) must be installed in the user/language directory.
 ** See for more information */
define( 'YOURLS_LANG', '' ); 

/** Allow multiple short URLs for a same long URL
 ** Set to true to have only one pair of shortURL/longURL (default YOURLS behavior)
 ** Set to false to allow multiple short URLs pointing to the same long URL ( behavior) */
define( 'YOURLS_UNIQUE_URLS', true );

/** Private means the Admin area will be protected with login/pass as defined below.
 ** Set to false for public usage (eg on a restricted intranet or for test setups)
 ** Read for more details if you're unsure */
define( 'YOURLS_PRIVATE', true );

/** A random secret hash used to encrypt cookies. You don't have to remember it, make it long and complicated. Hint: copy from **/
define( 'YOURLS_COOKIEKEY', '2fZNpH}3Xyk2wU4Sv[qsH-nw~VEMm_6B&v#xBsV5' );

/** Username(s) and password(s) allowed to access the site. Passwords either in plain text or as encrypted hashes
 ** YOURLS will auto encrypt plain text passwords in this file
 ** Read for more information */
$yourls_user_passwords = array(
    'gilbn' => 'myyourlsuserpassword' /* Password encrypted by YOURLS */ ,
    // 'username2' => 'password2',
    // You can have one or more 'login'=>'password' lines

Save the config file and restart the swag container.

Next go to and finish the installation.

Note: will give you a 403 Forbidden error. That’s normal.

From the YOURLS FAQ:

There is no index page at the root of the install

  • Indeed. It’s intended. It’s up to the user to make what they need. Some will redirect the root to a different place, some make a public interface for anyone to shorten links, some make a portfolio. You make it.
  • If you want to make a public interface and run your own little, there’s a sample file provided as an example: sample-public-front-page.txt. This implies important issues to deal with: spam, performance and security. Read Public Shortening for important information.

If you need any extra help join the Discord server!


Allowing mobile apps to work with services using Organizr server auth How to set up a WordPress site with letsencrypt/swag and MariaDB on Unraid Redirecting visitors to a 403 forbidden page when accessing the WordPress admin page