Open-source URL shortener - Solution for URL shortening: nginx, postgres, json
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 77 commits ahead of bastilian:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
android_app @ 56f958a
conf
script
tizen_app @ 0bfd03b
website
.gitmodules
LICENSE
README.md

README.md

urlhda

Open-source URL shortener - Solution for URL shortening: nginx, postgres, json

Includes: Website, android application, tizen application and simple bash script for url shortening

Features:

  • Strong URL (15 symbols long uid for shorted URLs, 5 symbols by default)
  • Fast copy-paste. Auto selection in browser, and copy button in android app
  • Ability to share URLs (Android App only) Live example: hda.me

To use it as a service

  • You can use hda.me website
  • You can use HDA URL (Urlhda) android application
    Get it on F-Droid
  • Or you can use Urlhda from CLI Install it via PPA.
sudo apt-add-repository ppa:hda-me/urlhda
sudo apt-get update
sudo apt-get install urlhda

Or copy this script to /usr/local/bin

Setup it yourself

Requirements

Configuration examples location and installation

  • conf folder includes nginx.conf section example, site-enabled/sitename (vhost) example, sql file to import and debian rules file example, useful for package rebuild
  • script folder includes shortening bash script example
  • website folder includes url shortener website page example
  • android_app android application, used for hda.me url shortener website
  • tizen app tizen application, used for hda.me url shortener website

Once you have nginx and modules installed you can start nginx with the the configuration from /conf and /website folders You also need to setup a database in your PostgreSQL-server and create separate table, don't forget set password. Use the /config/database.sql file to do it for you. After you are done adjust the settings to your environment in the nginx configuration.

Creating user and database:

CREATE USER "user" WITH PASSWORD 'password';  
CREATE DATABASE databasename WITH OWNER "user";  

Importing:

psql -h localhost -d databasename -U user -f database.sql

Upgrading old installation (database) for Strong URLs support:

\c databasename
ALTER TABLE links ALTER COLUMN uid TYPE character varying(30);

Usage

  1. Script
    Edit host, chmod 755, and copy to /usr/local/bin/ Or you can install it via PPA:
sudo apt-add-repository ppa:hda-me/urlhda
sudo apt-get update
sudo apt-get install urlhda
# 5 symbols uid (default)  
urlhda http[s]://your_long_url_here  
# To generate Strong URL (15 symbols uid)  
urlhda -s http[s]://your_long_url_here 
  1. Website
    Edit index.html to change appearance for your needs and your done
  2. Android application
    Install app and change hostname URL in application Settings (gear icon)

How it works

You can shorten URLs with a POST-request:

  curl -X POST https://website.name/add?url=http://add.me

This will give you JSON-response back with the generated 5 character UID:

[{"uid":"abcd5"}]

With that you can go to for example to https://website.name/abcd5 and you will be redirected to http://add.me

Other

Original idea: Sebastian Gräßl, forked from https://github.com/bastilian/sebas
Bitcoin donate: 1N5czHaoSLukFSTq2ZJujaWGjkmBxv2dT9