Skip to content

Another URL Shortener with analytics based on Nginx and Redis

License

Notifications You must be signed in to change notification settings

popeye0807/shorturl-nginx

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

shorturl-nginx

A URL Shortener with analytics based on Nginx and Redis

Setup

  • Start a redis instance
  • Build your nginx with lua-nginx-module and set-misc-nginx-module
  • Copy the lua script conf/lua/n3r/urlshortener_eval.lua to your own nginx conf/lua/n3r/ directory, and update the redis configurations in the connect function
  • Copy the html/shorten-ui.html to your own nginx html directory
  • Download lua-resty-redis and copy the lib/resty/redis.lua to your own nginx conf/lua/resty/ directory
  • Add the follow configurations to your nginx.conf, then start your nginx

http block: lua_package_path

server block: location a)shorten-ui.html b)shorten c)^/0[0-9a-zA-Z]{1,12}$

You could find these configurations in my conf/nginx.conf

Basic Usage

Create a short url

http://localhost:8088/shorten?url=http://www.google.com

NOTE: Do not forget the http:// prefix within the url parameter

Visit the short url

Just visit the url that the previous step returned

Web UI

http://localhost:8088/shorten-ui.html

NOTE: In this page, you could input a URL, then get the shorten form

Create a random short url

http://localhost:8088/shorten?url=http://www.google.com&random=true

Query source url by the short

http://localhost:8088/shorten-qrybyshort?url=http://t.cn/0asd

About

Another URL Shortener with analytics based on Nginx and Redis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%