Jump to content

UWSGI

From NixOS Wiki

uWSGI web application server for different programming languages such as Python, Perl or Ruby. Implementing the WSGI-protocol.

Setup

Following example configuration illustrates how to serve the Python web app Oncall usgin the uWSGI module

services.uwsgi = {
  enable = true;
  plugins = [ "python3" ];
  instance = {
    type = "emperor";
    vassals = {
      oncall = {
        type = "normal";
        env = [
          "PYTHONPATH=${pkgs.oncall.pythonPath}"
          "STATIC_ROOT=/var/lib/oncall"
        ];
        module = "oncall.app:get_wsgi_app()";
        socket = "${config.services.uwsgi.runDir}/oncall.sock";
        socketGroup = "nginx";
        immediate-gid = "nginx";
        chmod-socket = "770";
        pyargv = "${pkgs.oncall}/share/configs/config.yaml";
        buffer-size = 32768;
      };
    };
  };
};

services.nginx = {
  enable = lib.mkDefault true;
  virtualHosts."localhost".locations = {
    "/".extraConfig = "uwsgi_pass unix://${config.services.uwsgi.runDir}/oncall.sock;";
  };
};

The application will be available on http://localhost.