### unitctl instances new command with Docker Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Shows how to start a new Unit container using `unitctl instances new`. The command takes three arguments: a socket path or TCP address, an application path, and an image tag. The example mounts /tmp/2 to /var/run and the current directory to /www, and uses the unit:wasm image. The container runs on the host network. ```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 ``` -------------------------------- ### Install NGINX Unit on Debian derivatives Source: https://github.com/nginx/unit/blob/master/README.md Installs Unit on Debian-based systems using apt. ```console # apt install unit ``` -------------------------------- ### Download and install unitctl binary Source: https://github.com/nginx/unit/blob/master/README.md Extracts the unitctl binary from the downloaded tarball and moves it to /usr/local/bin/. This step can be skipped if Unit was installed via Homebrew. ```console $ tar xzvf unitctl-master-x86_64-unknown-linux-gnu.tar.gz # mv unitctl /usr/local/bin/ ``` -------------------------------- ### GET /status/applications/{appName}/processes/starting Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the starting processes app status number 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 ### Parameters #### Path Parameters - **appName** (string) - Required - The name of the application. ``` -------------------------------- ### Install NGINX Unit on Fedora derivatives Source: https://github.com/nginx/unit/blob/master/README.md Installs Unit on Fedora-based systems using yum. ```console # yum install unit ``` -------------------------------- ### Install NGINX Unit on macOS with Homebrew Source: https://github.com/nginx/unit/blob/master/README.md Installs both unitd and unitctl using Homebrew. Requires the nginx/unit tap. ```console $ brew install nginx/unit/unit ``` -------------------------------- ### unitc local configuration examples Source: https://github.com/nginx/unit/blob/master/tools/README.md Examples of using unitc with a local Unit instance. The control socket is automatically detected, and the error log is monitored unless the -l or --nolog option is used. ```shell unitc /config unitc /config < unitconf.json echo '{"*:8080": {"pass": "routes"}}' | unitc /config/listeners unitc /config/applications/my_app DELETE unitc /certificates/bundle cert.pem key.pem ``` -------------------------------- ### unitc docker configuration examples Source: https://github.com/nginx/unit/blob/master/tools/README.md Examples of using unitc with Docker containers. The docker:// prefix specifies the local container ID/name, and the default Unix control socket can be overridden. ```shell unitc docker://d43251184c54 /config echo '{"http": {"log_route": true}}' | unitc docker://d43251184c54 /settings unitc docker://f4f3d9e918e6/root/unit.sock /control/applications/my_app/restart UNIT_CTRL=docker://4d0431488982 unitc /status/requests/total ``` -------------------------------- ### GET /config Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the entire configuration. ```APIDOC ## GET /config ### Description Retrieves the entire configuration. ### Method GET ### Endpoint /config ### Response #### Success Response (200) Returns the full configuration object. ``` -------------------------------- ### GET /certificates/{bundleName}/chain/{arrayIndex}/validity/since Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the starting time of certificate validity. ```APIDOC ## GET /certificates/{bundleName}/chain/{arrayIndex}/validity/since ### Description Retrieve the starting time of certificate validity. ### Method GET ### Endpoint /certificates/{bundleName}/chain/{arrayIndex}/validity/since ### Parameters #### Path Parameters - **bundleName** (string) - Required - The name of the certificate bundle. - **arrayIndex** (integer) - Required - The index of the certificate in the chain. ### Response #### Success Response (200) Returns the starting time. ``` -------------------------------- ### GET /config/applications Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the applications object. ```APIDOC ## GET /config/applications ### Description Retrieves the applications object. ### Method GET ### Endpoint /config/applications ### Response #### Success Response (200) Returns the applications object. ``` -------------------------------- ### GET /config/applications Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the applications object. ```APIDOC ## GET /config/applications ### Description Retrieve the applications object ### Method GET ### Endpoint /config/applications ### Response #### Success Response (200) No response body is specified. ``` -------------------------------- ### GET /config/settings Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the settings object. ```APIDOC ## GET /config/settings ### Description Retrieves the settings object. ### Method GET ### Endpoint /config/settings ``` -------------------------------- ### GET /config/settings Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the settings object. ```APIDOC ## GET /config/settings ### Description Retrieves the settings object. ### Method GET ### Endpoint /config/settings ### Response #### Success Response (200) Returns the settings object. ``` -------------------------------- ### GET /config/listeners Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve all the listeners. ```APIDOC ## GET /config/listeners ### Description Retrieve all the listeners. ### Method GET ### Endpoint /config/listeners ### Response #### Success Response (200) Returns a list of listeners. ``` -------------------------------- ### GET /config/listeners Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves all the listeners. ```APIDOC ## GET /config/listeners ### Description Retrieves all the listeners. ### Method GET ### Endpoint /config/listeners ### Response #### Success Response (200) Returns a collection of listener objects. ``` -------------------------------- ### Install GNU core utilities on macOS Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Required for macOS users to install GNU core utilities via Homebrew before building unitctl. ```bash $ brew install make gnu-sed grep gawk maven ``` -------------------------------- ### setup-unit repo-config Source: https://github.com/nginx/unit/blob/master/tools/README.md Configures the package manager with the NGINX Unit repository for later installation. ```APIDOC ## setup-unit repo-config ### Description Configures the package manager with the NGINX Unit repository for later installation. ### Usage ``` setup-unit repo-config ``` ``` -------------------------------- ### GET /config/routes Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the routes entity. ```APIDOC ## GET /config/routes ### Description Retrieves the routes entity. ### Method GET ### Endpoint /config/routes ``` -------------------------------- ### unitc remote configuration examples Source: https://github.com/nginx/unit/blob/master/tools/README.md Examples of using unitc with a remote NGINX Unit instance. The remote control socket can be set with the $UNIT_CTRL environment variable and accessed over TCP, SSH, or Docker. SSH is recommended for remote configuration. ```shell unitc http://192.168.0.1:8080/status UNIT_CTRL=http://192.168.0.1:8080 unitc /status export UNIT_CTRL=ssh://root@unithost/var/run/control.unit.sock unitc /config/routes cat catchall_route.json | unitc POST /config/routes echo '{"match":{"uri":"/wp-admin/*"},"action":{"return":403}}' | unitc INSERT /config/routes ``` -------------------------------- ### GET /config/routes Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the routes entity. ```APIDOC ## GET /config/routes ### Description Retrieves the routes entity. ### Method GET ### Endpoint /config/routes ### Response #### Success Response (200) Returns the routes entity. ``` -------------------------------- ### GET /config/settings/listen_threads Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the listen_threads option from settings. ```APIDOC ## GET /config/settings/listen_threads ### Description Retrieves the listen_threads option from settings. ### Method GET ### Endpoint /config/settings/listen_threads ``` -------------------------------- ### GET /config/settings/listen_threads Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the listen_threads option from settings. ```APIDOC ## GET /config/settings/listen_threads ### Description Retrieves the listen_threads option from settings. ### Method GET ### Endpoint /config/settings/listen_threads ### Parameters None ### Response #### Success Response (200) Returns the listen_threads value. #### Response Example ```json { "listen_threads": 1 } ``` ``` -------------------------------- ### GET /config/applications/{appName} Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves an application object by name. ```APIDOC ## GET /config/applications/{appName} ### Description Retrieves an application object by name. ### Method GET ### Endpoint /config/applications/{appName} ### Parameters #### Path Parameters - **appName** (string) - Required - The name of the application. ### Response #### Success Response (200) Returns the application object. ``` -------------------------------- ### GET /control/applications/{appName}/restart Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Restart the {appName} application. ```APIDOC ## GET /control/applications/{appName}/restart ### Description Restart the {appName} application. ### Method GET ### Endpoint /control/applications/{appName}/restart ### Parameters #### Path Parameters - **appName** (string) - Required - The name of the application to restart. ``` -------------------------------- ### GET /config/listeners/{listenerName} Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve a listener object. ```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. ``` -------------------------------- ### GET /certificates Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the certificates object. ```APIDOC ## GET /certificates ### Description Retrieve the certificates object. ### Method GET ### Endpoint /certificates ### Response #### Success Response (200) Returns the certificates object. ``` -------------------------------- ### GET /config/settings/http/static Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the static object from http settings. ```APIDOC ## GET /config/settings/http/static ### Description Retrieves the static object from http settings. ### Method GET ### Endpoint /config/settings/http/static ``` -------------------------------- ### GET /config/settings/http Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the http object from settings. ```APIDOC ## GET /config/settings/http ### Description Retrieves the http object from settings. ### Method GET ### Endpoint /config/settings/http ``` -------------------------------- ### GET /config/settings/http Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the http object from settings. ```APIDOC ## GET /config/settings/http ### Description Retrieves the http object from settings. ### Method GET ### Endpoint /config/settings/http ### Response #### Success Response (200) Returns the http object. ``` -------------------------------- ### GET /status/applications Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the applications status object. ```APIDOC ## GET /status/applications ### Description Retrieve the applications status object. ### Method GET ### Endpoint /status/applications ``` -------------------------------- ### GET /config/settings/http/server_version Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the server_version option from http settings. ```APIDOC ## GET /config/settings/http/server_version ### Description Retrieves the server_version option from http settings. ### Method GET ### Endpoint /config/settings/http/server_version ``` -------------------------------- ### GET /config/settings/http/static Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the static object from HTTP settings. ```APIDOC ## GET /config/settings/http/static ### Description Retrieves the static object from HTTP settings. ### Method GET ### Endpoint /config/settings/http/static ### Parameters None ### Response #### Success Response (200) Returns the static object. #### Response Example ```json { "static": {} } ``` ``` -------------------------------- ### GET /config/listeners/{listenerName}/tls/conf_commands Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the conf_commands object 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 ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ### Response #### Success Response (200) Returns the conf_commands object. ``` -------------------------------- ### GET /config/applications/{appName} Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves an application object specified by appName. ```APIDOC ## GET /config/applications/{appName} ### Description Retrieve an application object ### Method GET ### Endpoint /config/applications/{appName} ### Parameters #### Path Parameters - **appName** (string) - Required - The name of the application ### Response #### Success Response (200) No response body is specified. ``` -------------------------------- ### GET /config/settings/http/server_version Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the server_version option from HTTP settings. ```APIDOC ## GET /config/settings/http/server_version ### Description Retrieves the server_version option from HTTP settings. ### Method GET ### Endpoint /config/settings/http/server_version ### Parameters None ### Response #### Success Response (200) Returns the server_version value. #### Response Example ```json { "server_version": true } ``` ``` -------------------------------- ### setup-unit welcome Source: https://github.com/nginx/unit/blob/master/tools/README.md Creates an initial configuration to serve a welcome web page with NGINX Unit. ```APIDOC ## setup-unit welcome ### Description Creates an initial configuration to serve a welcome web page with NGINX Unit. ### Usage ``` setup-unit welcome ``` ``` -------------------------------- ### GET /config/listeners/{listenerName}/tls/conf_commands Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the conf_commands object in a listener. ```APIDOC ## GET /config/listeners/{listenerName}/tls/conf_commands ### Description Retrieves 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. ### Response #### Success Response (200) Returns the conf_commands object. #### Response Example ```json { "conf_commands": {} } ``` ``` -------------------------------- ### Configure package repositories with setup-unit script Source: https://github.com/nginx/unit/blob/master/README.md Downloads and runs the setup-unit helper script to configure the correct package repositories for Debian, Ubuntu, Amazon Linux, Fedora, and Red Hat systems. ```console $ wget https://raw.githubusercontent.com/nginx/unit/master/tools/setup-unit && chmod +x setup-unit # ./setup-unit repo-config ``` -------------------------------- ### Generate and open crate documentation with cargo doc --open Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Run this command in the crate directory to build and open the generated documentation in your default browser. ```bash cargo doc --open ``` -------------------------------- ### Edit Unit configuration interactively Source: https://github.com/nginx/unit/blob/master/README.md Opens the current Unit configuration in an interactive editor. The example configuration adds a listener on port 8000 that passes requests to the 'python' application, and defines that application with type 'python', path '/www/', and module 'wsgi'. Valid configurations are applied upon save and close. ```console $ unitctl edit ``` ```jsonc { "listeners": { "*:8000": { // Point listener to new application "pass": "applications/python" } }, // Add an application definition "applications": { "python": { "type": "python", "path": "/www/", "module": "wsgi" } } } ``` -------------------------------- ### GET /control/applications/{appName}/restart Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Restarts the specified application. ```APIDOC ## GET /control/applications/{appName}/restart ### Description Restart the {appName} application ### Method GET ### Endpoint /control/applications/{appName}/restart ### Parameters #### Path Parameters - **appName** (string) - Required - The name of the application to restart ### Response #### Success Response (200) No response body is specified. ``` -------------------------------- ### List available build targets with make list-targets Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Shows the available build targets for unitctl. The output lists the target platform, e.g., x86_64-unknown-linux-gnu. ```bash $ make list-targets x86_64-unknown-linux-gnu ``` -------------------------------- ### GET /config/listeners/{listenerName} Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves a listener object by name. ```APIDOC ## GET /config/listeners/{listenerName} ### Description Retrieves a listener object by name. ### Method GET ### Endpoint /config/listeners/{listenerName} ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ### Response #### Success Response (200) Returns the listener object. ``` -------------------------------- ### Example JSON object at /config/listeners/ Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Shows a JSON object stored at /config/listeners/, illustrating Unit's addressable configuration endpoints. ```json { "*:8080": { "pass": "applications/wp_emea_dev" } } ``` -------------------------------- ### Import configuration, certificates, and NJS modules with unitctl import Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Parses existing configuration, certificates, and NJS modules from a directory and converts them into a payload to reconfigure a Unit daemon. The example shows importing from /opt/unit/config. ```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 ``` -------------------------------- ### GET /certificates/{bundleName} Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the certificate bundle object. ```APIDOC ## GET /certificates/{bundleName} ### Description Retrieve the certificate bundle object ### Method GET ### Endpoint /certificates/{bundleName} ### Parameters #### Path Parameters - **bundleName** (string) - Required - The name of the certificate bundle ### Response #### Success Response (200) No response body is specified. ``` -------------------------------- ### GET /config/listeners/{listenerName}/tls/certificate Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the certificate option in a listener. ```APIDOC ## GET /config/listeners/{listenerName}/tls/certificate ### Description Retrieve the certificate option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/tls/certificate ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ### Response #### Success Response (200) Returns the certificate option. ``` -------------------------------- ### PHP Hello World script Source: https://github.com/nginx/unit/blob/master/README.md A minimal PHP script that outputs 'Hello, PHP on Unit!'. Save it as /www/helloworld/index.php. ```php ``` -------------------------------- ### GET /status Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the status object. ```APIDOC ## GET /status ### Description Retrieve the status object. ### Method GET ### Endpoint /status ``` -------------------------------- ### GET /config/listeners/{listenerName}/forwarded/source Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the source option in a listener. ```APIDOC ## GET /config/listeners/{listenerName}/forwarded/source ### Description Retrieve the source option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/forwarded/source ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ### Response #### Success Response (200) Returns the source option. ``` -------------------------------- ### GET /config/listeners/{listenerName}/tls/certificate/{arrayIndex} Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve a certificate array item in a listener. ```APIDOC ## GET /config/listeners/{listenerName}/tls/certificate/{arrayIndex} ### Description Retrieve a certificate array item in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/tls/certificate/{arrayIndex} ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. - **arrayIndex** (integer) - Required - The index of the certificate array item. ### Response #### Success Response (200) Returns the certificate array item. ``` -------------------------------- ### GET /config/listeners/{listenerName}/backlog Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the backlog option in a 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. ``` -------------------------------- ### GET /config/listeners/{listenerName}/tls Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the tls object in a 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. ### Response #### Success Response (200) Returns the tls object. ``` -------------------------------- ### GET /config/listeners/{listenerName}/tls/certificate/{arrayIndex} Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves a certificate array item in a listener. ```APIDOC ## GET /config/listeners/{listenerName}/tls/certificate/{arrayIndex} ### Description Retrieves a certificate array item in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/tls/certificate/{arrayIndex} ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. - **arrayIndex** (integer) - Required - The index of the certificate array item. ### Response #### Success Response (200) Returns the certificate array item. ``` -------------------------------- ### GET /config/listeners/{listenerName}/tls/certificate Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the certificate option in a listener. ```APIDOC ## GET /config/listeners/{listenerName}/tls/certificate ### Description Retrieves the certificate option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/tls/certificate ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ### Response #### Success Response (200) Returns the certificate option. #### Response Example ```json { "certificate": [] } ``` ``` -------------------------------- ### Run NGINX Unit with Docker Source: https://github.com/nginx/unit/blob/master/README.md Pulls the Unit image, creates a control socket directory, and runs the container with bind mounts for the control socket and current directory. The latest image tag may not support all language modules; check available tags before pulling. ```console $ 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 ``` -------------------------------- ### GET /config/listeners/{listenerName}/backlog Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the backlog option in a listener. ```APIDOC ## GET /config/listeners/{listenerName}/backlog ### Description Retrieves the backlog option in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/backlog ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ### Response #### Success Response (200) Returns the backlog option. ``` -------------------------------- ### unitctl CLI help output Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Shows the full command-line interface for unitctl, including subcommands (instances, edit, import, execute, status, listeners, apps, export) and options such as -s/--control-socket-address, -w/--wait-timeout-seconds, -t/--wait-max-tries, -h/--help, and -V/--version. The default for --wait-max-tries is 3. ```text CLI interface to the NGINX Unit Control API Usage: unitctl [OPTIONS] Commands: instances List all running Unit processes edit Open current Unit configuration in editor import Import configuration from a directory execute Sends raw JSON payload to Unit status Get the current status of Unit listeners List active listeners apps List all configured Unit applications export Export the current configuration of Unit help Print this message or the help of the given subcommand(s) Options: -s, --control-socket-address Path (unix:/var/run/unit/control.sock), tcp address with port (127.0.0.1:80), or URL. This flag can be specified multiple times. -w, --wait-timeout-seconds Number of seconds to wait for control socket to become available -t, --wait-max-tries Number of times to try to access control socket when waiting [default: 3] -h, --help Print help -V, --version Print version ``` -------------------------------- ### Export configuration from a running Unit instance with unitctl export Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Queries the control API to fetch running configuration and NJS modules. The output is saved as a tarball at the filename given with -f, or to standard out with -f -. The exported configuration omits certificates. Does not support multiple instances. ```bash $ unitctl export -f config.tar $ unitctl export -f - $ unitctl export -f - | tar xf - config.json $ unitctl export -f - > config.tar ``` -------------------------------- ### Create a new Unit instance with Docker Source: https://github.com/nginx/unit/blob/master/README.md Creates a new NGINX Unit instance using the unit:python Docker image. The /path/to/app directory is mounted to /www in the Docker filesystem. ```console $ unitctl instances new 127.0.0.1:8001 /path/to/app 'unit:python' ``` -------------------------------- ### GET /status/modules Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the modules status object. ```APIDOC ## GET /status/modules ### Description Retrieve the modules status object. ### Method GET ### Endpoint /status/modules ``` -------------------------------- ### GET /config/listeners/{listenerName}/forwarded/source/{arrayIndex} Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve a source array item in a listener. ```APIDOC ## GET /config/listeners/{listenerName}/forwarded/source/{arrayIndex} ### Description Retrieve a source array item in a listener. ### Method GET ### Endpoint /config/listeners/{listenerName}/forwarded/source/{arrayIndex} ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. - **arrayIndex** (integer) - Required - The index of the source array item. ### Response #### Success Response (200) Returns the source array item. ``` -------------------------------- ### GET /status/connections/idle Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the idle connections number. ```APIDOC ## GET /status/connections/idle ### Description Retrieve the idle connections number. ### Method GET ### Endpoint /status/connections/idle ``` -------------------------------- ### Add listener via curl Source: https://github.com/nginx/unit/blob/master/README.md PUTs a listener configuration that passes requests to the 'helloworld' application. The command sends the JSON directly from the command line. ```console # curl -X PUT -d '{"127.0.0.1:8080": {"pass": "applications/helloworld"}}' \ --unix-socket /path/to/control.unit.sock http://localhost/config/listeners ``` ```json { "success": "Reconfiguration done." } ``` -------------------------------- ### GET /status/connections/closed Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the closed connections number. ```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 active connections number. ```APIDOC ## GET /status/connections/active ### Description Retrieve the active connections number. ### Method GET ### Endpoint /status/connections/active ``` -------------------------------- ### PUT /config/applications/{appName} Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Creates or overwrites the application object specified by appName. ```APIDOC ## PUT /config/applications/{appName} ### Description Create or overwrite the application object ### Method PUT ### Endpoint /config/applications/{appName} ### Parameters #### Path Parameters - **appName** (string) - Required - The name of the application ### Response #### Success Response (200) No response body is specified. ``` -------------------------------- ### GET /status/connections/accepted Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the accepted connections number. ```APIDOC ## GET /status/connections/accepted ### Description Retrieve the accepted connections number. ### Method GET ### Endpoint /status/connections/accepted ``` -------------------------------- ### Test the app with curl Source: https://github.com/nginx/unit/blob/master/README.md Sends a GET request to the listener address. The output shows the PHP script's response. ```console $ curl 127.0.0.1:8080 Hello, PHP on Unit! ``` -------------------------------- ### PUT /config/applications/{appName} Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Creates or overwrites the application object. ```APIDOC ## PUT /config/applications/{appName} ### Description Creates or overwrites the application object. ### Method PUT ### Endpoint /config/applications/{appName} ### Parameters #### Path Parameters - **appName** (string) - Required - The name of the application. #### Request Body - **application** (object) - Required - The application configuration. ### Request Example ```json { "application": {} } ``` ### Response #### Success Response (200) Returns the updated configuration. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### GET /status/connections Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieve the connections status object. ```APIDOC ## GET /status/connections ### Description Retrieve the connections status object. ### Method GET ### Endpoint /status/connections ``` -------------------------------- ### Wait for socket to become available with unitctl --wait-timeout-seconds Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md All commands support waiting on unix sockets for availability. The example shows using --wait-timeout-seconds and --wait-max-tries flags with the import command, and the output when the timeout is exceeded. ```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 ``` -------------------------------- ### GET /config/settings/telemetry Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the telemetry object from settings. ```APIDOC ## GET /config/settings/telemetry ### Description Retrieves the telemetry object from settings. ### Method GET ### Endpoint /config/settings/telemetry ``` -------------------------------- ### Required packages for fuzzing Source: https://github.com/nginx/unit/blob/master/fuzzing/README.md Lists the minimum packages needed to build and run the fuzzers. Package names may vary by distribution. ```text clang, llvm & compiler-rt ``` -------------------------------- ### unitctl with multiple control sockets Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Shows how to pass multiple control socket addresses using the -s flag to operate on multiple Unit instances at once. The example uses a TCP address and a unix socket path. ```bash $ unitctl -s '127.0.0.1:8001' -s /run/nginx-unit.control.sock app list ``` -------------------------------- ### GET /config/settings/telemetry Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the telemetry object from settings. ```APIDOC ## GET /config/settings/telemetry ### Description Retrieves the telemetry object from settings. ### Method GET ### Endpoint /config/settings/telemetry ### Parameters None ### Response #### Success Response (200) Returns the telemetry object. #### Response Example ```json { "telemetry": {} } ``` ``` -------------------------------- ### Edit current configuration with unitctl edit Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Fetches the configuration from a running Unit instance and opens it in an editor. Uses the EDITOR environment variable, defaulting to vim, emacs, nano, vi, or pico. Does not support multiple instances. ```bash $ unitctl edit [[EDITOR LOADS SHOWING CURRENT CONFIGURATION - USER EDITS AND SAVES]] { "success": "Reconfiguration done." } ``` -------------------------------- ### GET /config/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 Retrieves the access log configuration. ### Method GET ### Endpoint /config/access_log ### Response #### Success Response (200) Returns the access log configuration object. ``` -------------------------------- ### PUT /config/settings Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Create or overwrite the settings object. ```APIDOC ## PUT /config/settings ### Description Create or overwrite the settings object. ### Method PUT ### Endpoint /config/settings ``` -------------------------------- ### PUT /config/settings/listen_threads Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Create or overwrite the listen_threads option in the settings. ```APIDOC ## PUT /config/settings/listen_threads ### Description Create or overwrite the listen_threads option. ### Method PUT ### Endpoint /config/settings/listen_threads ``` -------------------------------- ### GET /config/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 ### Response #### Success Response (200) No response body is specified. ``` -------------------------------- ### Build unitctl for a specific target Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Builds the unitctl binary for the specified target using the makefile. The output shows the build command and the resulting binary file details. ```bash $ make x86_64-unknown-linux-gnu ▶ building unitctl with flags [--quiet --release --bin unitctl --target x86_64-unknown-linux-gnu] ``` ```bash $ 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 ``` -------------------------------- ### unitctl apps list command output Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Shows the output of `unitctl apps list`, which lists configured applications from the control API. The example shows a wasm application of type wasm-wasi-component with a component path. ```bash $ unitctl apps list { "wasm": { "type": "wasm-wasi-component", "component": "/www/wasmapp-proxy-component.wasm" } } ``` -------------------------------- ### GET /config/settings/http/log_route Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the log_route option from http settings. ```APIDOC ## GET /config/settings/http/log_route ### Description Retrieves the log_route option from http settings. ### Method GET ### Endpoint /config/settings/http/log_route ``` -------------------------------- ### GET /config/settings/http/static/mime_types Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the mime_types object from static settings. ```APIDOC ## GET /config/settings/http/static/mime_types ### Description Retrieves the mime_types object from static settings. ### Method GET ### Endpoint /config/settings/http/static/mime_types ``` -------------------------------- ### unitc usage syntax Source: https://github.com/nginx/unit/blob/master/tools/README.md Shows the command-line syntax for unitc, a curl wrapper for managing NGINX Unit configuration. The URI specifies the target in Unit's control API, configuration data is read from stdin, and jq is used to prettify JSON output if available. ```text USAGE: unitc [options] URI ``` -------------------------------- ### GET /config/settings/http/send_timeout Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the send_timeout option from http settings. ```APIDOC ## GET /config/settings/http/send_timeout ### Description Retrieves the send_timeout option from http settings. ### Method GET ### Endpoint /config/settings/http/send_timeout ``` -------------------------------- ### GET /config/settings/http/max_body_size Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the max_body_size option from http settings. ```APIDOC ## GET /config/settings/http/max_body_size ### Description Retrieves the max_body_size option from http settings. ### Method GET ### Endpoint /config/settings/http/max_body_size ``` -------------------------------- ### GET /config/settings/http/idle_timeout Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the idle_timeout option from http settings. ```APIDOC ## GET /config/settings/http/idle_timeout ### Description Retrieves the idle_timeout option from http settings. ### Method GET ### Endpoint /config/settings/http/idle_timeout ``` -------------------------------- ### PUT /config/listeners/{listenerName}/tls/conf_commands Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Create or overwrite the conf_commands object in a listener. ```APIDOC ## PUT /config/listeners/{listenerName}/tls/conf_commands ### Description Create or overwrite the conf_commands object in a listener. ### Method PUT ### Endpoint /config/listeners/{listenerName}/tls/conf_commands ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ``` -------------------------------- ### GET /config/settings/http/header_read_timeout Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the header_read_timeout option from http settings. ```APIDOC ## GET /config/settings/http/header_read_timeout ### Description Retrieves the header_read_timeout option from http settings. ### Method GET ### Endpoint /config/settings/http/header_read_timeout ``` -------------------------------- ### List active listeners with unitctl listeners Source: https://github.com/nginx/unit/blob/master/tools/unitctl/README.md Queries the control API to list all configured listeners. If no socket path is provided, it attempts to detect from a running instance. Supports multiple instances via the -s flag. ```bash unitctl listeners No socket path provided - attempting to detect from running instance { "127.0.0.1:8080": { "pass": "routes" } } ``` ```bash $ unitctl -s '127.0.0.1:8001' -s /run/nginx-unit.control.sock listeners ``` -------------------------------- ### GET /config/settings/http/body_read_timeout Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the body_read_timeout option from http settings. ```APIDOC ## GET /config/settings/http/body_read_timeout ### Description Retrieves the body_read_timeout option from http settings. ### Method GET ### Endpoint /config/settings/http/body_read_timeout ``` -------------------------------- ### GET /config/settings/http/discard_unsafe_fields Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the discard_unsafe_fields option from http settings. ```APIDOC ## GET /config/settings/http/discard_unsafe_fields ### Description Retrieves the discard_unsafe_fields option from http settings. ### Method GET ### Endpoint /config/settings/http/discard_unsafe_fields ``` -------------------------------- ### Upload application config via curl Source: https://github.com/nginx/unit/blob/master/README.md PUTs the config.json file to the /config/applications section of Unit's control API using a Unix domain socket. The expected response is a success message. ```console # curl -X PUT --data-binary @config.json --unix-socket \ /path/to/control.unit.sock http://localhost/config/applications ``` ```json { "success": "Reconfiguration done." } ``` -------------------------------- ### GET /config/settings/http/log_route Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the log_route option from HTTP settings. ```APIDOC ## GET /config/settings/http/log_route ### Description Retrieves the log_route option from HTTP settings. ### Method GET ### Endpoint /config/settings/http/log_route ### Parameters None ### Response #### Success Response (200) Returns the log_route value. #### Response Example ```json { "log_route": false } ``` ``` -------------------------------- ### Application object JSON for PHP app Source: https://github.com/nginx/unit/blob/master/README.md Defines the 'helloworld' application with type 'php' and root '/www/helloworld/'. Store this in config.json for later use. ```json { "helloworld": { "type": "php", "root": "/www/helloworld/" } } ``` -------------------------------- ### GET /config/settings/http/static/mime_types Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the mime_types object from static settings. ```APIDOC ## GET /config/settings/http/static/mime_types ### Description Retrieves the mime_types object from static settings. ### Method GET ### Endpoint /config/settings/http/static/mime_types ### Parameters None ### Response #### Success Response (200) Returns the mime_types object. #### Response Example ```json { "mime_types": {} } ``` ``` -------------------------------- ### PUT /config/listeners Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Create or overwrite all the listeners. ```APIDOC ## PUT /config/listeners ### Description Create or overwrite all the listeners. ### Method PUT ### Endpoint /config/listeners ``` -------------------------------- ### GET /config/settings/http/send_timeout Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the send_timeout option from HTTP settings. ```APIDOC ## GET /config/settings/http/send_timeout ### Description Retrieves the send_timeout option from HTTP settings. ### Method GET ### Endpoint /config/settings/http/send_timeout ### Parameters None ### Response #### Success Response (200) Returns the send_timeout value. #### Response Example ```json { "send_timeout": 30 } ``` ``` -------------------------------- ### GET /config/settings/http/max_body_size Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the max_body_size option from HTTP settings. ```APIDOC ## GET /config/settings/http/max_body_size ### Description Retrieves the max_body_size option from HTTP settings. ### Method GET ### Endpoint /config/settings/http/max_body_size ### Parameters None ### Response #### Success Response (200) Returns the max_body_size value. #### Response Example ```json { "max_body_size": 1048576 } ``` ``` -------------------------------- ### PUT /config/listeners/{listenerName}/tls/conf_commands Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Creates or overwrites the conf_commands object in a listener. ```APIDOC ## PUT /config/listeners/{listenerName}/tls/conf_commands ### Description Creates or overwrites the conf_commands object in a listener. ### Method PUT ### Endpoint /config/listeners/{listenerName}/tls/conf_commands ### Parameters #### Path Parameters - **listenerName** (string) - Required - The name of the listener. ``` -------------------------------- ### PUT /config/settings/http/server_version Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Create or overwrite the server_version option in the HTTP settings. ```APIDOC ## PUT /config/settings/http/server_version ### Description Create or overwrite the server_version option. ### Method PUT ### Endpoint /config/settings/http/server_version ``` -------------------------------- ### GET /config/settings/http/idle_timeout Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the idle_timeout option from HTTP settings. ```APIDOC ## GET /config/settings/http/idle_timeout ### Description Retrieves the idle_timeout option from HTTP settings. ### Method GET ### Endpoint /config/settings/http/idle_timeout ### Parameters None ### Response #### Success Response (200) Returns the idle_timeout value. #### Response Example ```json { "idle_timeout": 60 } ``` ``` -------------------------------- ### GET /config/settings/http/header_read_timeout Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the header_read_timeout option from HTTP settings. ```APIDOC ## GET /config/settings/http/header_read_timeout ### Description Retrieves the header_read_timeout option from HTTP settings. ### Method GET ### Endpoint /config/settings/http/header_read_timeout ### Parameters None ### Response #### Success Response (200) Returns the header_read_timeout value. #### Response Example ```json { "header_read_timeout": 30 } ``` ``` -------------------------------- ### GET /config/settings/http/body_read_timeout Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the body_read_timeout option from HTTP settings. ```APIDOC ## GET /config/settings/http/body_read_timeout ### Description Retrieves the body_read_timeout option from HTTP settings. ### Method GET ### Endpoint /config/settings/http/body_read_timeout ### Parameters None ### Response #### Success Response (200) Returns the body_read_timeout value. #### Response Example ```json { "body_read_timeout": 30 } ``` ``` -------------------------------- ### GET /config/settings/http/discard_unsafe_fields Source: https://github.com/nginx/unit/blob/master/tools/unitctl/unit-openapi/README.md Retrieves the discard_unsafe_fields option from http settings. ```APIDOC ## GET /config/settings/http/discard_unsafe_fields ### Description Retrieves the discard_unsafe_fields option from http settings. ### Method GET ### Endpoint /config/settings/http/discard_unsafe_fields ### Response #### Success Response (200) Returns the discard_unsafe_fields option. ```