Serving a single File with NGinx

Let's start with the NGinx configuration. More information serving static content

We want to serve a single file planets-alpha.apk

location /planets-alpha.apk { alias /var/www/public_files/Planets2-0.3.0-265ea345-release.apk; }

We decided to use alias to keep the freedom of changing the filename easily.

A nice explanation about choosing root/alias: Nginx - root versus alias, for serving single files?

Within the promotion.html we added the new static link:

<a class="qrcode" style="width:150px" href="/planets-alpha.apk">Planets2 Android Client</a>

You certainly spotted the class qrcode and guess what's coming next. JavaScript fiddling with this class.

var qrimg = function(url, width) {
  if (width.endsWith("px")) width = parseInt(width);
  if (!(width > 0)) width = 200;
  return "http://chart.apis.google.com/chart?cht=qr&chs="+width+"x"+width+"&choe=UTF-8&chld=L&chl=" + escape(url);
};

$(function() {
  $("a.qrcode").each(function() {
    $(this).html($("<img/>", { src: qrimg($(this).attr("href"), $(this).css("width")), alt: $(this).text(), title: $(this).text() }))
  })
});

Fine. A QR Code....what's next?