Skip to main content

ngxctl

A modern command-line utility for generating, managing, validating, and applying Nginx configurations.

Python Nginx MIT License Linux CLI

A cleaner way to work with Nginx.


Overview

ngxctl is an open-source command-line utility that simplifies the process of creating, managing, validating, and deploying Nginx configurations.

Whether you're deploying a personal project, hosting a production API, or setting up multiple virtual hosts on a VPS, ngxctl eliminates repetitive configuration work while keeping every generated file clean, readable, and fully editable.

Instead of manually creating server blocks, enabling sites, validating syntax, and reloading Nginx, ngxctl automates the workflow through a simple and intuitive command-line interface.

The goal isn't to replace Nginx.

The goal is to make working with Nginx faster, safer, and significantly less repetitive.


Why ngxctl?

Working with Nginx often involves repeating the same workflow:

  • Create a new configuration.
  • Copy an old server block.
  • Replace the domain.
  • Replace the backend port.
  • Enable the site.
  • Test the configuration.
  • Reload Nginx.

Repeat that enough times and it becomes tedious.

ngxctl automates those repetitive steps while still generating standard Nginx configuration files that you can edit manually whenever you need to.


Features

Configuration Generation

  • Reverse proxy configuration
  • Static website hosting
  • Single Page Application (SPA) support
  • PHP-FPM applications
  • Docker reverse proxy templates
  • WebSocket support
  • SSL-ready templates
  • HTTP → HTTPS redirects

Supported Backends

Backend Supported
Node.js
Express
NestJS
FastAPI
Flask
Django
Go
PHP-FPM
Docker Containers
Static Websites
React
Vue
Svelte

Site Management

  • Create new sites
  • Enable existing sites
  • Disable sites
  • Delete sites
  • List configured sites
  • Inspect configurations
  • Automatic symlink management

Service Management

  • Validate configurations using nginx -t
  • Reload Nginx
  • Restart Nginx
  • Safe validation before reload

Backup & Recovery

  • Automatic snapshot creation
  • Timestamped backups
  • Restore previous configurations
  • Backup listing
  • Rollback support

Installation

Requirements

Before installing ngxctl, ensure you have:

  • Python 3.12 or newer
  • Nginx installed
  • Linux-based operating system

Install from PyPI

pip install ngxctl-cli

Install with pipx

pipx install git+https://github.com/thexento/ngxctl.git

Install from Source

Clone the repository.

git clone https://github.com/thexento/ngxctl.git

Move into the project.

cd ngxctl

Create a virtual environment.

python3 -m venv .venv
source .venv/bin/activate

Install the project.

pip install -e .

Quick Start

Launch the interactive setup wizard.

ngxctl create

The wizard guides you through:

  • Domain name
  • Site type
  • Backend configuration
  • Output location
  • Automatic validation
  • Automatic reload

Usage

Reverse Proxy

ngxctl create reverse-proxy \
    --domain api.example.com \
    --port 3000

Custom backend URL.

ngxctl create reverse-proxy \
    --domain api.example.com \
    --proxy-pass http://127.0.0.1:8080

Enable WebSocket support.

ngxctl create reverse-proxy \
    --domain socket.example.com \
    --port 3000 \
    --websocket

Static Website

ngxctl create static \
    --domain example.com \
    --root /var/www/example

SPA Support.

ngxctl create static \
    --domain app.example.com \
    --root /var/www/app/dist \
    --spa

PHP

ngxctl create php \
    --domain blog.example.com \
    --root /var/www/blog

Site Management

List all sites.

ngxctl list

Inspect a site.

ngxctl inspect mysite

Enable a site.

ngxctl enable mysite

Disable a site.

ngxctl disable mysite

Delete a site.

ngxctl delete mysite

Nginx Operations

Validate configuration.

ngxctl test

Reload Nginx.

ngxctl reload

Restart Nginx.

ngxctl restart

Display service status.

ngxctl status

Backup Management

Create a backup.

ngxctl backup create mysite

List backups.

ngxctl backup list

Restore a backup.

ngxctl backup restore mysite

Delete a backup.

ngxctl backup delete mysite

Environment Variables

Variable Description Default
NGXCTL_NGINX_DIR Base Nginx directory /etc/nginx
NGXCTL_SITES_AVAILABLE Sites Available directory /etc/nginx/sites-available
NGXCTL_SITES_ENABLED Sites Enabled directory /etc/nginx/sites-enabled
NGXCTL_CONF_D conf.d directory /etc/nginx/conf.d
NGXCTL_BACKUP_DIR Backup directory System Default

Project Structure

ngxctl/
├── commands/
├── helpers/
├── templates/
├── utils/
├── __init__.py
├── __main__.py
├── cli.py
└── generator.py

Design Principles

ngxctl follows a few simple principles.

  • Keep commands intuitive.
  • Generate clean and readable configurations.
  • Avoid unnecessary complexity.
  • Never apply invalid configurations.
  • Keep everything modular.
  • Produce standard Nginx files.
  • Allow manual editing at any time.

Example Workflow

Generate a reverse proxy.

ngxctl create

Validate the generated configuration.

ngxctl test

Reload Nginx.

ngxctl reload

Done.


Contributing

Contributions are welcome.

If you would like to improve the project:

git clone https://github.com/thexento/ngxctl.git

cd ngxctl

git checkout -b feature/my-feature

# Make your changes

git commit -m "Add my feature"

git push origin feature/my-feature

Then open a Pull Request describing your changes.

Please keep contributions focused, readable, and well documented.


Frequently Asked Questions

Does ngxctl replace Nginx?

No.

ngxctl generates and manages Nginx configuration files. Nginx itself remains responsible for serving traffic.


Are generated configurations editable?

Yes.

Every generated configuration is a normal Nginx configuration file and can be modified manually.


Does ngxctl modify existing files?

Only when instructed to do so.

Whenever possible, backup snapshots are created before overwriting configurations.


Which operating systems are supported?

Currently, the primary target is Linux systems running Nginx.


License

This project is licensed under the MIT License.

See the LICENSE file for more information.


Developed and maintained by Xento

GitHub: https://github.com/thexento

If you find this project useful, consider giving it a star.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ngxctl_cli-0.1.2.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ngxctl_cli-0.1.2-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file ngxctl_cli-0.1.2.tar.gz.

File metadata

  • Download URL: ngxctl_cli-0.1.2.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.5

File hashes

Hashes for ngxctl_cli-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f55790f8a4cad74fc40d03dfc092fb8cde4e340afae223719ad863ebfa251d63
MD5 f7879f8cb413871da4c2f0fdea2dd5ef
BLAKE2b-256 3f6c06d63749d38451fd5ac3cbd120998602228dfe1b7e8e2d52a004f0ff8f9a

See more details on using hashes here.

File details

Details for the file ngxctl_cli-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ngxctl_cli-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.5

File hashes

Hashes for ngxctl_cli-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1207dd2012901827885ea73cf5947fa52ba0558205d1116684bb610a1d3980fe
MD5 6dcb3ea1596df78e092483318a78f841
BLAKE2b-256 52e81a450261a4add83cd28a41f20cd38abbf44ec875f88fc397f6deef50adb3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page