MAAS with nginx proxy pass

After installing Metal As A Service on a server at work that already had nginx listening on port 80, I had to work out a solution to expose the MAAS resources via nginx instead of apache.

This is what I came up with (on Ubuntu 14.04.4 LTS):

2016-02-25 Update: The command line interface for MAAS requires the API to be on the default server instance so I had to make it the internal interface’s default target and configure /etc/resolv.conf to use the MAAS name server (which forwards to the real name servers for anything not related to MAAS). Also I think I found a bug where if you change the name of the cluster controller, the CLI won’t find it any more.

upstream maas {
        server localhost:5240;
}

server {
        listen 192.168.33.1:80 default;
        listen *:80;

        root /usr/share/maas/web;
        index index.html index.htm;
        server_name maas.example.com;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }

        location /MAAS/static/ {
                alias /usr/share/maas/web/static/ ;
        }
        location /MAAS/ws {
                proxy_pass http://maas;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }
        location /MAAS/ {
                proxy_pass http://maas;
        }
}
comments powered by Disqus