Shlink is a PHP-based self-hosted URL shortener that can be used to serve shortened URLs under your own domain.
Dokku is the smallest PaaS implementation you've ever seen - Docker powered mini-Heroku.
- A working Dokku host
- PostgreSQL plugin for Dokku
- Letsencrypt plugin for SSL (optionnal)
Note: Throughout this guide, we will use the domain shlink.example.com
for demonstration purposes. Make sure to replace it with your actual domain name.
Log into your Dokku host and create the Shlink app:
dokku apps:create shlink
# Install postgres plugin on Dokku
dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
# Create running plugin
dokku postgres:create shlink
# Link plugin to the main app
dokku postgres:link shlink shlink
dokku config:set shlink DEFAULT_DOMAIN=shlink.example.com
To enable routing for the Shlink app, we need to configure the domain. Execute the following command:
dokku domains:set shlink shlink.example.com
Begin by cloning this repository onto your local machine.
# Via SSH
git clone git@github.com:d1ceward/shlink_on_dokku.git
# Via HTTPS
git clone https://github.com/d1ceward/shlink_on_dokku.git
Now, set up your Dokku server as a remote repository.
git remote add dokku dokku@example.com:shlink
Now, you can push the Shlink app to Dokku. Ensure you have completed this step before moving on to the next section.
git push dokku master
Lastly, let's obtain an SSL certificate from Let's Encrypt.
# Install letsencrypt plugin
dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
# Set certificate contact email
dokku letsencrypt:set shlink email you@example.com
# Generate certificate
dokku letsencrypt:enable shlink
Congratulations! Your Shlink instance is now up and running, and you can access it at https://shlink.example.com.