Giter Site home page Giter Site logo

shorturl-nginx's Introduction

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

shorturl-nginx's People

Contributors

sanshi0518 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.