Skip to content

Solution for URL shortening: nginx, postgres, json

License

Notifications You must be signed in to change notification settings

UdoKifferbrehl/urlhda

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

urlhda

Solution for URL shortening: nginx, postgres, json.
Includes: website, android application, and simple bash script for url shortening.
Live example: hda.me

## 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 main url shortener website page example
  • android_app folder includes example android application, where apk file is actual application used for hda.me url shortener website.

Once you have nginx and the needed modules installed you can start nginx up with the the configuration in this found in /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.
Example:
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

##Usage

  1. Script
    Edit host, chmod 755, and copy to /usr/local/bin/ Usage: urlhda http[s]://your_long_url_here
  2. Website
    Install, configure, edit index.html to change appearance for your needs and your done.
  3. Android app
    Change host in index.html, import to android studio, sign apk with your personal key and finally build apk.

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

About

Solution for URL shortening: nginx, postgres, json

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Makefile 44.8%
  • HTML 31.5%
  • Java 20.5%
  • Shell 3.2%