### Install Nginx Unit on Debian/Ubuntu Source: https://context7.com/nginx/unit/llms.txt Installs Nginx Unit and specific language modules on Debian/Ubuntu systems using provided setup script and apt. ```bash wget https://raw.githubusercontent.com/nginx/unit/master/tools/setup-unit chmod +x setup-unit && sudo ./setup-unit repo-config sudo apt install unit unit-python3.12 unit-php unit-jsc17 ``` -------------------------------- ### Start Nginx Unit with Docker Source: https://context7.com/nginx/unit/llms.txt Quickly starts an Nginx Unit instance with a Python module using Docker. Mounts control socket and current directory. ```bash docker pull unit:python mkdir /tmp/unit-control docker run -d \ --mount type=bind,src=/tmp/unit-control,dst=/var/run \ --mount type=bind,src=$(pwd),dst=/www \ --network host \ unit:python ``` -------------------------------- ### Start New Unit Instance with unitctl Source: https://context7.com/nginx/unit/llms.txt Starts a new Nginx Unit instance using Docker. Requires the instance address, application path, and module type. ```bash unitctl instances new 127.0.0.1:8001 /path/to/myapp 'unit:python' ``` -------------------------------- ### Install NGINX Unit on Debian/Ubuntu Source: https://github.com/nginx/unit/blob/master/README.md Installs the NGINX Unit package on Debian or Ubuntu systems after configuring the repositories. ```bash # apt install unit ``` -------------------------------- ### Install NGINX Unit with Homebrew Source: https://github.com/nginx/unit/blob/master/README.md Installs both the Unit daemon (unitd) and the control tool (unitctl) on macOS using Homebrew. ```bash $ brew install nginx/unit/unit ``` -------------------------------- ### Extract and Install unitctl Binary Source: https://github.com/nginx/unit/blob/master/README.md Extracts the unitctl binary from a tarball and moves it to the system's PATH. This is for manual installation if not using Homebrew. ```bash $ tar xzvf unitctl-master-x86_64-unknown-linux-gnu.tar.gz # mv unitctl /usr/local/bin/ ``` -------------------------------- ### Get Status Applications App Processes Starting Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the number of starting processes for a specific application. ```APIDOC ## GET /status/applications/{appName}/processes/starting ### Description Retrieve the starting processes app status number. ### Method GET ### Endpoint /status/applications/{appName}/processes/starting ``` -------------------------------- ### Install NGINX Unit on Fedora/Red Hat Source: https://github.com/nginx/unit/blob/master/README.md Installs the NGINX Unit package on Fedora or Red Hat based systems after configuring the repositories. ```bash # yum install unit ``` -------------------------------- ### Install GNU Core Utilities on macOS Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Macintosh users may need to install GNU core utilities using brew before building unitctl. ```bash $ brew install make gnu-sed grep gawk maven ``` -------------------------------- ### Get Listeners Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve all configured listeners. ```APIDOC ## GET /config/listeners ### Description Retrieve all the listeners. ### Method GET ### Endpoint /config/listeners ``` -------------------------------- ### Get Applications Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the applications object from the Unit configuration. ```APIDOC ## GET /config/applications ### Description Retrieve the applications object. ### Method GET ### Endpoint /config/applications ``` -------------------------------- ### Start unitd Manually with TCP Control Socket Source: https://context7.com/nginx/unit/llms.txt Starts the unitd daemon manually with a TCP control socket enabled on port 9090 and logs directed to a file. This enables OpenAPI tools. ```bash unitd --control 127.0.0.1:9090 --log /var/log/unit/unit.log ``` -------------------------------- ### Get Server Version Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the configured server version string. ```APIDOC ## GET /config/settings/http/server_version ### Description Retrieve the server_version option from http settings. ### Method GET ### Endpoint /config/settings/http/server_version ``` -------------------------------- ### Get Config Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the entire Unit configuration object. ```APIDOC ## GET /config ### Description Retrieve the config. ### Method GET ### Endpoint /config ``` -------------------------------- ### Full Unit Configuration Output Source: https://github.com/nginx/unit/blob/master/README.md An example of the complete configuration output from Unit's control API, showing both listeners and applications. ```json { "listeners": { "127.0.0.1:8080": { "pass": "applications/helloworld" } }, "applications": { "helloworld": { "type": "php", "root": "/www/helloworld/" } } } ``` -------------------------------- ### Configure NGINX Unit Repository Source: https://github.com/nginx/unit/blob/master/tools/README.md Use `setup-unit repo-config` to configure your package manager with the NGINX Unit repository for easier installation. ```shell setup-unit repo-config ``` -------------------------------- ### Configure Unit Package Repositories Source: https://github.com/nginx/unit/blob/master/README.md Downloads and executes a helper script to configure the correct package repositories for installing NGINX Unit on Debian/Ubuntu or Fedora/Red Hat based systems. ```bash wget https://raw.githubusercontent.com/nginx/unit/master/tools/setup-unit && chmod +x setup-unit # ./setup-unit repo-config ``` -------------------------------- ### Get Routes Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the routes object from the Unit configuration. ```APIDOC ## GET /config/routes ### Description Retrieve the routes entity. ### Method GET ### Endpoint /config/routes ``` -------------------------------- ### Get Settings Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the global settings object from the Unit configuration. ```APIDOC ## GET /config/settings ### Description Retrieve the settings object. ### Method GET ### Endpoint /config/settings ``` -------------------------------- ### Start New Unit Instance with Docker Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Launches a new Unit container using Docker. Specify a control API endpoint (socket or TCP), an application path to mount, and the image tag. The `-r` flag can be used for read-only application volume mounts. ```bash $ unitctl instances new /tmp/2 $(pwd) 'unit:wasm' Pulling and starting a container from unit:wasm Will mount /tmp/2 to /var/run for socket access Will mount /home/user/repositories/nginx/unit/tools/unitctl to /www for application access Note: Container will be on host network ``` -------------------------------- ### Get Settings HTTP Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the HTTP settings object. ```APIDOC ## GET /config/settings/http ### Description Retrieve the http object from settings. ### Method GET ### Endpoint /config/settings/http ``` -------------------------------- ### Get Application Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves a specific application object by its name. ```APIDOC ## GET /config/applications/{appName} ### Description Retrieve an application object. ### Method GET ### Endpoint /config/applications/{appName} ``` -------------------------------- ### Example NGINX Unit Configuration Endpoint Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Illustrates how NGINX Unit's API exposes configuration as addressable endpoints. Object options are addressable by name, and array items by index. ```json { "*:8080": { "pass": "applications/wp_emea_dev" } } ``` -------------------------------- ### Get Telemetry Settings Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the current configuration for telemetry. ```APIDOC ## GET /config/settings/telemetry ### Description Retrieve the `telemetry` object from settings. ### Method GET ### Endpoint /config/settings/telemetry ``` -------------------------------- ### ApplicationsApi - Get Applications Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the entire applications object, listing all configured applications. ```APIDOC ## Get Applications ### Description Retrieve the applications object ### Method Get ### Endpoint /config/applications ``` -------------------------------- ### Get Settings HTTP Static Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the static object from the HTTP settings. ```APIDOC ## GET /config/settings/http/static ### Description Retrieve the static object from http settings. ### Method GET ### Endpoint /config/settings/http/static ``` -------------------------------- ### Get Access Log Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the access log configuration. ```APIDOC ## GET /config/access_log ### Description Retrieve the access log. ### Method GET ### Endpoint /config/access_log ``` -------------------------------- ### Get Listener Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves a specific listener object from the Unit configuration. ```APIDOC ## GET /config/listeners/{listenerName} ### Description Retrieve a listener object. ### Method GET ### Endpoint /config/listeners/{listenerName} ``` -------------------------------- ### Manage NGINX Unit Full Configuration Source: https://context7.com/nginx/unit/llms.txt Use the `/config` endpoint to retrieve, replace, or delete the entire Unit configuration atomically. This is useful for initial setup or complete reconfigurations. ```bash # GET the full configuration curl --unix-socket /var/run/control.unit.sock http://localhost/config | jq . # Expected output: # { # "listeners": { ... }, # "applications": { ... }, # "routes": { ... }, # "settings": { ... }, # "access_log": "/var/log/unit/access.log" # } ``` ```bash # PUT a complete configuration (replaces everything atomically) curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ "listeners": { "*:8080": { "pass": "routes" } }, "routes": [ { "match": { "uri": "/api/*" }, "action": { "pass": "applications/backend" } }, { "action": { "share": "/www/static$uri" } } ], "applications": { "backend": { "type": "python 3.12", "working_directory": "/www/backend/", "module": "wsgi", "processes": 4 } }, "access_log": "/var/log/unit/access.log" }' \ http://localhost/config # {"success": "Reconfiguration done."} ``` ```bash # DELETE the entire configuration curl -X DELETE --unix-socket /var/run/control.unit.sock http://localhost/config # {"success": "Reconfiguration done."} ``` -------------------------------- ### Create Initial NGINX Unit Welcome Page Configuration Source: https://github.com/nginx/unit/blob/master/tools/README.md Use `setup-unit welcome` to create an initial configuration that serves a welcome web page with NGINX Unit. ```shell setup-unit welcome ``` -------------------------------- ### Deploy and Restart Application Script Source: https://context7.com/nginx/unit/llms.txt A script demonstrating deployment via rsync followed by a graceful restart of the application, with basic success checking. ```bash rsync -a /deploy/myapp/ /www/myapp/ curl -s --unix-socket /var/run/control.unit.sock \ http://localhost/control/applications/myapp/restart | \ grep -q '"success"' && echo "Restarted successfully" || echo "Restart failed" ``` -------------------------------- ### Configure OpenTelemetry Tracing Source: https://context7.com/nginx/unit/llms.txt Sets up OpenTelemetry (OTEL) tracing to export spans to a collector. Requires Unit to be built with the `--otel` flag. This example configures a local Jaeger collector. ```bash curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ "endpoint": "http://jaeger:4318/v1/traces", "protocol": "http", "batch_size": 256, "sampling_ratio": 0.1 }' \ http://localhost/config/settings/telemetry ``` -------------------------------- ### Get Status of All Applications with unitctl Source: https://context7.com/nginx/unit/llms.txt Retrieves the status of all applications managed by Nginx Unit. ```bash unitctl status ``` -------------------------------- ### Query Unit Configuration via Control API Source: https://github.com/nginx/unit/blob/master/README.md Use curl to query the entire configuration of Unit by sending a GET request to the `/config/` endpoint via a Unix domain socket. ```console # curl --unix-socket /path/to/control.unit.sock http://localhost/config/ ``` -------------------------------- ### ApplicationsApi - Get Application Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves a specific application object by its name. ```APIDOC ## Get Application ### Description Retrieve an application object ### Method Get ### Endpoint /config/applications/{appName} ``` -------------------------------- ### Get Log Route Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the configured route for logging HTTP requests. ```APIDOC ## GET /config/settings/http/log_route ### Description Retrieve the log_route option from http settings. ### Method GET ### Endpoint /config/settings/http/log_route ``` -------------------------------- ### Import Configuration from Directory Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Parses configuration files, certificates, and NJS modules from a specified directory and converts them into a payload to reconfigure a Unit daemon. ```bash $ unitctl import /opt/unit/config Imported /opt/unit/config/certificates/snake.pem -> /certificates/snake.pem Imported /opt/unit/config/hello.js -> /js_modules/hello.js Imported /opt/unit/config/put.json -> /config Imported 3 files ``` -------------------------------- ### Build unitctl with Make Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Build available unitctl binary targets using the provided makefile. Use 'list-targets' to see available platforms. ```bash $ make list-targets x86_64-unknown-linux-gnu $ make x86_64-unknown-linux-gnu ▶ building unitctl with flags [--quiet --release --bin unitctl --target x86_64-unknown-linux-gnu] $ file ./target/x86_64-unknown-linux-gnu/release/unitctl ./target/x86_64-unknown-linux-gnu/release/unitctl: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=ef4b094ffd549b39a8cb27a7ba2cc0dbad87a3bc, for GNU/Linux 4.4.0, with debug_info, not stripped ``` -------------------------------- ### Get Listen Threads Setting Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the current value of the listen_threads option from the server settings. ```APIDOC ## Get Listen Threads Setting ### Description Retrieve the listen_threads option from settings. ### Method GET ### Endpoint /config/settings/listen_threads ``` -------------------------------- ### Open Live Configuration for Editing with unitctl Source: https://context7.com/nginx/unit/llms.txt Opens the live Nginx Unit configuration for interactive editing using the default editor. ```bash unitctl edit ``` -------------------------------- ### Get Status Requests Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the status object for all requests. ```APIDOC ## GET /status/requests ### Description Retrieve the requests status object. ### Method GET ### Endpoint /status/requests ``` -------------------------------- ### Get Status Modules Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the status object for all modules. ```APIDOC ## GET /status/modules ### Description Retrieve the modules status object. ### Method GET ### Endpoint /status/modules ``` -------------------------------- ### Get Full Status Snapshot with curl Source: https://context7.com/nginx/unit/llms.txt Fetches the complete status of the Nginx Unit instance. Requires jq for pretty-printing the JSON output. ```bash curl --unix-socket /var/run/control.unit.sock http://localhost/status | jq . ``` -------------------------------- ### Get Status Connections Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the status object for all connections. ```APIDOC ## GET /status/connections ### Description Retrieve the connections status object. ### Method GET ### Endpoint /status/connections ``` -------------------------------- ### Get NGINX Unit Configuration Source: https://github.com/nginx/unit/blob/master/tools/README.md Use `unitc` to retrieve the current NGINX Unit configuration for a specified URI. The output is prettified with `jq` if available. ```shell unitc /config ``` -------------------------------- ### Get Status Applications Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the status object for all applications. ```APIDOC ## GET /status/applications ### Description Retrieve the applications status object. ### Method GET ### Endpoint /status/applications ``` -------------------------------- ### Run NGINX Unit with Docker Source: https://github.com/nginx/unit/blob/master/README.md Pulls the Unit Docker image and runs it, mounting local directories for control sockets and web content. Ensure to replace `` with the desired image tag. ```bash $ docker pull unit: $ mkdir /tmp/unit-control # customize as needed. $ docker run -d \ --mount type=bind,src=/tmp/unit-control,dst=/var/run \ --mount type=bind,src=.,dst=/www \ --network host \ unit ``` -------------------------------- ### Wait for Unit Socket Availability Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Commands can optionally wait for the Unit control socket to become available before proceeding. This example demonstrates setting a timeout and maximum retry count. ```bash $ unitctl --wait-timeout-seconds=3 --wait-max-tries=4 import /opt/unit/config` Waiting for 3s control socket to be available try 2/4... Waiting for 3s control socket to be available try 3/4... Waiting for 3s control socket to be available try 4/4... Timeout waiting for unit to start has been exceeded ``` -------------------------------- ### Apply Configuration File with unitc Source: https://context7.com/nginx/unit/llms.txt Applies a configuration from a JSON file to the Nginx Unit instance. ```bash unitc /config < full-config.json ``` -------------------------------- ### Get HTTP Server Version Setting Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the current value of the server_version option within the http settings. ```APIDOC ## Get HTTP Server Version Setting ### Description Retrieve the server_version option from http settings. ### Method GET ### Endpoint /config/settings/http/server_version ``` -------------------------------- ### Configure Global HTTP Settings with Compression Source: https://context7.com/nginx/unit/llms.txt Sets comprehensive HTTP settings, including timeouts, body size, server version, debug logging, static file MIME types, and response compression configurations. ```bash curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ "body_read_timeout": 30, "header_read_timeout": 30, "send_timeout": 60, "idle_timeout": 180, "max_body_size": 67108864, "discard_unsafe_fields": true, "server_version": false, "log_route": false, "compression": { "types": ["text/*", "application/json", "application/javascript"], "compressors": [ { "encoding": "br", "min_length": 1024 }, { "encoding": "gzip", "level": 6, "min_length": 1024 }, { "encoding": "deflate", "min_length": 2048 }, { "encoding": "zstd", "level": 3, "min_length": 512 } ] }, "static": { "mime_types": { "application/wasm": ".wasm", "text/x-code": [".c", ".h", ".go", ".rs"] } } }' \ http://localhost/config/settings/http ``` -------------------------------- ### Get Listener Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve a specific listener object by its name. ```APIDOC ## GET /config/listeners/{listenerName} ### Description Retrieve a listener object. ### Method GET ### Endpoint /config/listeners/{listenerName} ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener to retrieve. ``` -------------------------------- ### Load NGINX Unit Configuration from File Source: https://github.com/nginx/unit/blob/master/tools/README.md Pipe a JSON configuration file to `unitc` to load it into NGINX Unit. This is useful for applying complex configurations. ```shell unitc /config < unitconf.json ``` -------------------------------- ### Configure Access Log Path (Simple String) Source: https://context7.com/nginx/unit/llms.txt Sets the access log path using a simple string. This will use the default Combined Log Format. ```bash curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '"/var/log/unit/access.log"' \ http://localhost/config/access_log ``` -------------------------------- ### Get Status Requests Total Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the total number of requests. ```APIDOC ## GET /status/requests/total ### Description Retrieve the total requests number. ### Method GET ### Endpoint /status/requests/total ``` -------------------------------- ### Configure Python ASGI App with Virtual Environment and Process Scaling Source: https://context7.com/nginx/unit/llms.txt Use this to configure a Python 3.12 ASGI application, specifying process scaling, working directory, module, protocol, virtual environment path, user/group, logging, environment variables, limits, and isolation settings. ```bash curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ "type": "python 3.12", "processes": { "max": 16, "spare": 4, "idle_timeout": 60 }, "working_directory": "/www/app/", "module": "main:app", "protocol": "asgi", "home": "/www/app/.venv", "user": "www", "group": "www", "stdout": "/var/log/unit/app.stdout.log", "stderr": "/var/log/unit/app.stderr.log", "environment": { "DJANGO_SETTINGS_MODULE": "app.settings.prod" }, "limits": { "timeout": 30, "requests": 10000 }, "isolation": { "rootfs": "/www/", "namespaces": { "network": false, "pid": true } } }' \ http://localhost/config/applications/myapp ``` -------------------------------- ### Get Status Connections Idle Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the number of idle connections. ```APIDOC ## GET /status/connections/idle ### Description Retrieve the idle connections number. ### Method GET ### Endpoint /status/connections/idle ``` -------------------------------- ### List Running Unit Instances with unitctl Source: https://context7.com/nginx/unit/llms.txt Lists all currently running Nginx Unit instances managed by unitctl. ```bash unitctl instances list ``` -------------------------------- ### Get Status Connections Closed Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the number of closed connections. ```APIDOC ## GET /status/connections/closed ### Description Retrieve the closed connections number. ### Method GET ### Endpoint /status/connections/closed ``` -------------------------------- ### Get Status Connections Active Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the number of active connections. ```APIDOC ## GET /status/connections/active ### Description Retrieve the active connections number. ### Method GET ### Endpoint /status/connections/active ``` -------------------------------- ### Configure Custom Apache-Style Access Log Source: https://context7.com/nginx/unit/llms.txt Sets a custom access log format mimicking the Apache Combined Log Format. Ensure all variables are correctly specified. ```bash curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ "path": "/var/log/unit/access.log", "format": "$remote_addr - $remote_user [$time_local] \"$request_line\" $status $body_bytes_sent \"$header_referer\" \"$header_user_agent\"" }' \ http://localhost/config/access_log ``` -------------------------------- ### Get Status Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the current status object of the Unit server. ```APIDOC ## GET /status ### Description Retrieve the status object. ### Method GET ### Endpoint /status ``` -------------------------------- ### Configure Unit Listener via Control API Source: https://github.com/nginx/unit/blob/master/README.md Use curl to send a PUT request to the Unit control API to configure a listener. The configuration is provided directly as a JSON string on the command line, specifying the pass to the 'helloworld' application. ```console # curl -X PUT -d '{"127.0.0.1:8080": {"pass": "applications/helloworld"}}' \ --unix-socket /path/to/control.unit.sock http://localhost/config/listeners ``` -------------------------------- ### Get Listener TLS Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the TLS object for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/tls ### Description Retrieve the tls object in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/tls ``` -------------------------------- ### Launch Unit Python Instance with Docker Source: https://github.com/nginx/unit/blob/master/README.md Use `unitctl` to launch a new Unit instance with a Python application using Docker. The application path is mounted to `/www` within the Docker container. ```console $ unitctl instances new 127.0.0.1:8001 /path/to/app 'unit:python' ``` -------------------------------- ### Get Listener Pass Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the pass option for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/pass ### Description Retrieve the pass option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/pass ``` -------------------------------- ### Configure Python ASGI Application Source: https://context7.com/nginx/unit/llms.txt Configure a Python ASGI application with virtual environment and process scaling settings. ```APIDOC ## PUT /config/applications/myapp ### Description Configures a Python ASGI application, specifying details like runtime, process scaling, working directory, module, protocol, virtual environment path, user/group, logging, environment variables, limits, and isolation settings. ### Method PUT ### Endpoint /config/applications/myapp ### Request Body - **type** (string) - Required - The application runtime type (e.g., "python 3.12"). - **processes** (object) - Optional - Process scaling configuration. - **max** (integer) - Maximum number of processes. - **spare** (integer) - Number of spare processes. - **idle_timeout** (integer) - Timeout for idle processes. - **working_directory** (string) - Required - The working directory for the application. - **module** (string) - Required - The module and application object (e.g., "main:app"). - **protocol** (string) - Required - The application protocol (e.g., "asgi"). - **home** (string) - Required - Path to the virtual environment. - **user** (string) - Optional - User to run the application as. - **group** (string) - Optional - Group to run the application as. - **stdout** (string) - Optional - Path for stdout log. - **stderr** (string) - Optional - Path for stderr log. - **environment** (object) - Optional - Environment variables for the application. - **limits** (object) - Optional - Resource limits. - **timeout** (integer) - Request timeout. - **requests** (integer) - Maximum requests per process. - **isolation** (object) - Optional - Process isolation settings. - **rootfs** (string) - Root filesystem path. - **namespaces** (object) - Namespace configuration. - **network** (boolean) - Enable network namespace. - **pid** (boolean) - Enable PID namespace. ### Request Example ```json { "type": "python 3.12", "processes": { "max": 16, "spare": 4, "idle_timeout": 60 }, "working_directory": "/www/app/", "module": "main:app", "protocol": "asgi", "home": "/www/app/.venv", "user": "www", "group": "www", "stdout": "/var/log/unit/app.stdout.log", "stderr": "/var/log/unit/app.stderr.log", "environment": { "DJANGO_SETTINGS_MODULE": "app.settings.prod" }, "limits": { "timeout": 30, "requests": 10000 }, "isolation": { "rootfs": "/www/", "namespaces": { "network": false, "pid": true } } } ``` ### Response #### Success Response (200) - **success** (string) - Indicates successful reconfiguration. ``` -------------------------------- ### Get Listener Forwarded Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the forwarded object for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/forwarded ### Description Retrieve the forwarded object in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/forwarded ``` -------------------------------- ### List Listener TLS Configuration Commands Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the TLS configuration commands for a listener. ```APIDOC ## GET /config/listeners/{listenerName}/tls/conf_commands ### Description Retrieve the conf_commands object in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/tls/conf_commands ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ``` -------------------------------- ### Get Listener Backlog Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the backlog option for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/backlog ### Description Retrieve the backlog option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/backlog ``` -------------------------------- ### Prepare Seed Corpora Directories Source: https://github.com/nginx/unit/blob/master/fuzzing/README.md Create directories to store seed corpora for various fuzzing targets. These directories are essential for initializing the fuzzing process. ```shell $ mkdir -p build/fuzz_basic_seed $ mkdir -p build/fuzz_http_controller_seed $ mkdir -p build/fuzz_http_h1p_seed $ mkdir -p build/fuzz_http_h1p_peer_seed $ mkdir -p build/fuzz_json_seed ``` -------------------------------- ### Get Telemetry Settings Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the telemetry object from the server settings. ```APIDOC ## Get Telemetry Settings ### Description Retrieve the `telemetry` object from settings. ### Method GET ### Endpoint /config/settings/telemetry ``` -------------------------------- ### Configure PHP App with Multiple Targets Source: https://context7.com/nginx/unit/llms.txt Configure a PHP application with multiple targets, defining different root directories and script entry points for different URI paths. Options for specific targets and a global PHP ini file can also be set. ```bash curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ "type": "php", "targets": { "main": { "root": "/www/wordpress/", "index": "index.php" }, "admin": { "root": "/www/wordpress/wp-admin/", "script": "index.php" } }, "options": { "admin": { "memory_limit": "256M", "upload_max_filesize": "64M" }, "file": "/etc/unit/php.ini" } }' \ http://localhost/config/applications/wordpress ``` -------------------------------- ### List Running Unit Instances Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Lists all running NGINX Unit processes and provides details such as PID, API control socket, child process IDs, runtime flags, and configuration options. ```bash $ unitctl instances No socket path provided - attempting to detect from running instance unitd instance [pid: 79489, version: 1.32.0]: Executable: /opt/unit/sbin/unitd API control unix socket: unix:/opt/unit/control.unit.sock Child processes ids: 79489, 79489 Runtime flags: --no-daemon Configure options: --prefix=/opt/unit --user=elijah --group=elijah --openssl ``` -------------------------------- ### Get Listener TLS Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the TLS object for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/tls ### Description Retrieve the tls object in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/tls ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ``` -------------------------------- ### Interactive Configuration Editing with unitc Source: https://context7.com/nginx/unit/llms.txt Opens the specified configuration section in the default editor ($EDITOR) for interactive editing. ```bash unitc edit /config/routes ``` -------------------------------- ### Get Listener Pass Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the pass option for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/pass ### Description Retrieve the pass option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/pass ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ``` -------------------------------- ### Apply Route Configuration with unitctl Source: https://context7.com/nginx/unit/llms.txt Applies a route configuration from a JSON file to the Nginx Unit instance. The configuration is set at /config/routes. ```bash cat routes.json | unitctl config set /config/routes ``` -------------------------------- ### Get Listener Forwarded Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the forwarded object for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/forwarded ### Description Retrieve the forwarded object in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/forwarded ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ``` -------------------------------- ### Get Listener Backlog Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the backlog option for a specific listener. ```APIDOC ## GET /config/listeners/{listenerName}/backlog ### Description Retrieve the backlog option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/backlog ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ``` -------------------------------- ### Configure WebAssembly WASI Component Source: https://context7.com/nginx/unit/llms.txt Configure a WebAssembly WASI component, specifying the path to the component file and the filesystem paths it can access. ```bash curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ "type": "wasm-wasi-component", "component": "/www/wasm/app.wasm", "access": { "filesystem": ["/www/data"] } }' \ http://localhost/config/applications/wasmapp ``` -------------------------------- ### Get Status Connections Accepted Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the total number of accepted connections. ```APIDOC ## GET /status/connections/accepted ### Description Retrieve the accepted connections number. ### Method GET ### Endpoint /status/connections/accepted ``` -------------------------------- ### Get Status Applications App Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the status object for a specific application. ```APIDOC ## GET /status/applications/{appName} ### Description Retrieve the app status object. ### Method GET ### Endpoint /status/applications/{appName} ``` -------------------------------- ### List Active Applications Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Queries a Unit control API to list all active applications. Supports operating on multiple instances using the `-s` flag. ```bash $ unitctl apps list { "wasm": { "type": "wasm-wasi-component", "component": "/www/wasmapp-proxy-component.wasm" } } ``` ```bash $ unitctl -s '127.0.0.1:8001' -s /run/nginx-unit.control.sock app list ``` -------------------------------- ### Get Access Log Path Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the access log path option. ```APIDOC ## GET /config/access_log/path ### Description Retrieve the access log path option. ### Method GET ### Endpoint /config/access_log/path ``` -------------------------------- ### Control API - Complete Configuration Source: https://context7.com/nginx/unit/llms.txt Retrieve, replace, or delete the entire NGINX Unit configuration atomically. This includes listeners, applications, routes, settings, and access logs. ```APIDOC ## GET /config ### Description Retrieves the entire Unit configuration as a single JSON document. ### Method GET ### Endpoint /config ### Request Example ```bash curl --unix-socket /var/run/control.unit.sock http://localhost/config | jq . ``` ### Response #### Success Response (200) - **listeners** (object) - Configuration for listeners. - **applications** (object) - Configuration for applications. - **routes** (object) - Configuration for routes. - **settings** (object) - Global settings. - **access_log** (string) - Path to the access log file. ### Response Example ```json { "listeners": { ... }, "applications": { ... }, "routes": { ... }, "settings": { ... }, "access_log": "/var/log/unit/access.log" } ``` ``` ```APIDOC ## PUT /config ### Description Replaces the entire Unit configuration atomically with the provided JSON document. ### Method PUT ### Endpoint /config ### Parameters #### Request Body - **listeners** (object) - Configuration for listeners. - **applications** (object) - Configuration for applications. - **routes** (object) - Configuration for routes. - **settings** (object) - Global settings. - **access_log** (string) - Path to the access log file. ### Request Example ```bash curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ ... }' \ http://localhost/config ``` ### Response #### Success Response (200) - **success** (string) - Confirmation message. ### Response Example ```json {"success": "Reconfiguration done."} ``` ``` ```APIDOC ## DELETE /config ### Description Deletes the entire Unit configuration. ### Method DELETE ### Endpoint /config ### Response #### Success Response (200) - **success** (string) - Confirmation message. ### Response Example ```json {"success": "Reconfiguration done."} ``` ``` -------------------------------- ### Get Access Log Format Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the access log format option. ```APIDOC ## GET /config/access_log/format ### Description Retrieve the access log format option. ### Method GET ### Endpoint /config/access_log/format ``` -------------------------------- ### CertificatesApi - Get Certificate Bundle Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves a certificate bundle object by its name. ```APIDOC ## Get Certificate Bundle ### Description Retrieve the certificate bundle object ### Method Get ### Endpoint /certificates/{bundleName} ``` -------------------------------- ### AccessLogApi - Get Access Log Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the current access log configuration. ```APIDOC ## Get Access Log ### Description Retrieve the access log ### Method Get ### Endpoint /config/access_log ``` -------------------------------- ### Add NGINX Unit Listener Configuration Source: https://github.com/nginx/unit/blob/master/tools/README.md Use `unitc` with a JSON payload piped from `echo` to configure new listeners in NGINX Unit. The `jq` tool is required for this operation. ```shell echo '{"*:8080": {"pass": "routes"}}' | unitc /config/listeners ``` -------------------------------- ### Get Status Modules Lang Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the status object for a specific language module. ```APIDOC ## GET /status/modules/{langMod} ### Description Retrieve the language module object. ### Method GET ### Endpoint /status/modules/{langMod} ``` -------------------------------- ### YAML Input/Output with unitc Source: https://context7.com/nginx/unit/llms.txt Interacts with the Nginx Unit configuration using YAML format. Use the -f yaml flag to specify the format. ```bash unitc -f yaml /config/settings ``` -------------------------------- ### Applications Configuration Source: https://context7.com/nginx/unit/llms.txt Define and configure application processes, specifying language type, process count, isolation, resource limits, and environment variables. ```APIDOC ## GET /config/applications/{appName} ### Description Retrieves the configuration for a specific application. ### Method GET ### Endpoint /config/applications/{appName} ### Parameters #### Path Parameters - **appName** (string) - The name of the application. ### Response #### Success Response (200) - **application_config** (object) - The configuration details of the application. ### Response Example ```json { "type": "python 3.12", "working_directory": "/www/backend/", "module": "wsgi", "processes": 4 } ``` ``` ```APIDOC ## PUT /config/applications/{appName} ### Description Creates or updates a specific application configuration. ### Method PUT ### Endpoint /config/applications/{appName} ### Parameters #### Path Parameters - **appName** (string) - The name of the application. #### Request Body - **type** (string) - The language type of the application (e.g., `python 3.12`). - **working_directory** (string) - The working directory for the application. - **module** (string) - The module to load for the application (e.g., `wsgi`). - **processes** (integer) - The number of application processes to run. - **isolation** (object) - Process isolation configuration. - **limits** (object) - Resource limits for the application processes. - **environment** (object) - Environment variables for the application. ### Request Example ```bash curl -X PUT --unix-socket /var/run/control.unit.sock \ -H "Content-Type: application/json" \ -d '{ ... }' \ "http://localhost/config/applications/backend" ``` ### Response #### Success Response (200) - **success** (string) - Confirmation message. ### Response Example ```json {"success": "Reconfiguration done."} ``` ``` ```APIDOC ## DELETE /config/applications/{appName} ### Description Removes a specific application configuration. ### Method DELETE ### Endpoint /config/applications/{appName} ### Parameters #### Path Parameters - **appName** (string) - The name of the application to remove. ### Response #### Success Response (200) - **success** (string) - Confirmation message. ### Response Example ```json {"success": "Reconfiguration done."} ``` ``` -------------------------------- ### Get Status Applications App Processes Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the status of processes for a specific application. ```APIDOC ## GET /status/applications/{appName}/processes ### Description Retrieve the processes app status object. ### Method GET ### Endpoint /status/applications/{appName}/processes ``` -------------------------------- ### Configure Routes Source: https://context7.com/nginx/unit/llms.txt Configure routing rules for handling incoming requests based on various match conditions and applying specific actions. ```APIDOC ## PUT /config/routes ### Description Configures routing rules, which are ordered arrays of match/action steps. Requests are evaluated top-to-bottom, and the first matching step's action is applied. Match conditions include URI, host, method, headers, query arguments, cookies, source/destination IP, and scheme. Actions can pass to an app, serve static files, proxy upstream, or return HTTP status codes. ### Method PUT ### Endpoint /config/routes ### Request Body - **secure** (array) - Optional - Array of route configurations for secure connections. - **api** (array) - Optional - Array of route configurations for API requests. - Each element in the arrays is an object with: - **match** (object) - Conditions to match the request. - **uri** (string or regex) - URI to match. - **host** (string or array) - Host header to match. - **method** (string or array) - HTTP method to match. - **headers** (object) - Headers to match. - **query** (object) - Query arguments to match. - **cookies** (object) - Cookies to match. - **source** (string) - Source IP address to match. - **destination** (string) - Destination IP address to match. - **scheme** (string) - Request scheme (http or https) to match. - **action** (object) - Action to perform if the match is successful. - **return** (integer) - Return an HTTP status code. - **location** (string) - Redirect location. - **pass** (string) - Pass the request to an application. - **proxy** (string) - Proxy the request to an upstream server. - **rewrite** (string) - Rewrite the request URI. - **response_headers** (object) - Headers to set in the response. - **share** (string or array) - Serve static files from specified paths. - **fallback** (object) - Fallback action if sharing fails. - **types** (array) - MIME types for static file serving. - **chroot** (string) - Change root directory for file serving. ### Request Example ```json { "secure": [ { "match": { "uri": "/wp-admin/*", "source": "!10.0.0.0/8" }, "action": { "return": 403 } }, { "match": { "uri": "~\.php$", "host": ["example.com", "www.example.com"], "method": ["GET", "POST"] }, "action": { "pass": "applications/wordpress/main" } }, { "match": { "headers": { "Accept": "*text/html*" } }, "action": { "share": ["/www/cache$uri.html", "/www/static$uri"], "fallback": { "pass": "applications/wordpress/main" } } }, { "action": { "share": "/www/static$uri", "types": ["image/*", "text/css", "application/javascript"], "chroot": "/www/" } } ], "api": [ { "match": { "uri": "/v1/*", "scheme": "https" }, "action": { "proxy": "http://127.0.0.1:3000", "rewrite": "/api$uri", "response_headers": { "Cache-Control": "no-store", "X-Powered-By": null } } }, { "action": { "return": 301, "location": "https://$host$request_uri" } } ] } ``` ### Response #### Success Response (200) - **success** (string) - Indicates successful reconfiguration. ``` -------------------------------- ### Get Listen Threads Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the number of threads configured for listening to incoming connections. ```APIDOC ## GET /config/settings/listen_threads ### Description Retrieve the listen_threads option from settings. ### Method GET ### Endpoint /config/settings/listen_threads ``` -------------------------------- ### Get Settings HTTP Send Timeout Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the send_timeout option from the HTTP settings. ```APIDOC ## GET /config/settings/http/send_timeout ### Description Retrieve the send_timeout option from http settings. ### Method GET ### Endpoint /config/settings/http/send_timeout ``` -------------------------------- ### Edit Unit Configuration Interactively Source: https://github.com/nginx/unit/blob/master/README.md Opens the Unit configuration in an interactive editor. Changes are applied upon saving and closing. ```console $ unitctl edit ``` -------------------------------- ### Get Settings HTTP Idle Timeout Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the idle_timeout option from the HTTP settings. ```APIDOC ## GET /config/settings/http/idle_timeout ### Description Retrieve the idle_timeout option from http settings. ### Method GET ### Endpoint /config/settings/http/idle_timeout ``` -------------------------------- ### CertificatesApi - Get Certificate Bundle Chain Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the certificate chain from a certificate bundle. ```APIDOC ## Get Certificate Bundle Chain ### Description Retrieve the certificate bundle chain ### Method Get ### Endpoint /certificates/{bundleName}/chain ``` -------------------------------- ### TlsApi: List Listener TLS Conf Commands Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the conf_commands object for TLS configuration in a listener. ```APIDOC ## GET /config/listeners/{listenerName}/tls/conf_commands ### Description Retrieve the conf_commands object in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/tls/conf_commands ```