Blog

  • Nginx Certbot

    Finally, after a week of headbanging, I managed to figure out certbot’s installation process with nginx and how to deploy python apps with uwsgi.

    1. Make sure that existing nginx is not listening on port 443

    There was a tiny trick with certbot’s nginx plugin - if you have a virtualhost, say, in /etc/nginx/sites-available/test.com, you must not listen on port 443. In other words, make sure that:

      server {
    
        # MAKE SURE THESE TWO LINES ARE COMMENTED
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
    
        ...
      }

    Otherwise, you might get a ‘connection reset by peer’ error. This is because there is already a listen on 443 on the default server block.

    2. Make sure that server_name is defined

    Nginx needs a virtualhost to be configured, so if you don’t include a configuration file with the server_name directive set, it will not work:

      server {
    
        # This does not work -  this is the default configuration
        server_name _;
    
        # Works
        server_name test.com www.test.com;
    
        ...
    
      }

  • Calling map on NodeList

    This blog post sums it up beautifully, though I don’t understand how a NodeList can be tricked so that one can call ‘map’ on it. If NodeList is a ‘subclass’ of Array, then it should ‘inherit’ the map function.

    For reference, if the link goes dead, here is how to call map on NodeList:

    1
    2
    3
    
    Array.prototype.map.call(nodelist, n => {
      console.log(n.innerHTML)
    })

  • Init Systems

    To learn what init system your linux box uses, you can do sudo stat /proc/1/exe, since init always runs with pid 1.

    The ansible service module is an abstraction over the underlying OS’s default init system. It’s systemd on Ubuntu 16.10 “Yaketty” (but upstart on 16.04 “Xenial”)

    Similarly, package is an abstraction over package managers, apt on Ubuntu but yum on Fedora. Each of these abstractions allow users to write more generic code, at the loss of more specific functionality that their OS specific counterparts provide(There are apt and yum modules, for example).