Using Nginx As A Simple URL Shortener

in linux

For a long time I used (and tinyurl before that) to provide friends and students with short URLs. But that was not perfect. Using meant I lost branding control, and that the URLs I wanted were not always available.

Owning a domain and a VPS makes it trivial to build your own url shortener. Here's how.

Shortening URLs with nginx

A URL shortener is just an HTTP server that responds with 301 when known shortcuts are accessed. The following nginx configuration does the trick:

server {

        location /ddg {
                return 301;

And now you can visit to reach duckduckgo.