/ Unix

Set up Supervisor Web UI behind nginx with tail function working

Supervisor (aka supervisord) is a well-known UNIX process control system.

It also includes a Web UI, allowing you to list current processes, start/stop them, tail their logs…

Set up the UI behind nginx, to access it with the /supervisord/ route for example, can however be tricky, especially to get the tail function to work.

First, make sure that your Supervisor configuration file (by default located in /etc/supervisord.conf) includes the following:

[inet_http_server]
port=127.0.0.1:9001
username=your_username
password=your_password

Note that setting a username and password is optional. Restart Supervisor to apply your new configuration.

service supervisor stop 
service supervisor start

The Supervisor HTTP server is now listening on port 9001.

Now for the nginx configuration to access the UI on /supervisord/:

server {
  
  location / supervisord/ {
    proxy_pass http://127.0.0.1:9001/;
    proxy_http_version 1.1;
    proxy_buffering     off;
    proxy_max_temp_file_size 0;
    proxy_redirect     default;
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    proxy_set_header   Connection       "";
  }
  
}

Do not forget the trailing slash in proxy_pass http://127.0.0.1:9001/;

The tail function of the Web UI should now be working. The proxy_buffering off;, proxy_http_version 1.1; and proxy_set_header Connection ""; did the trick for me.