Skip to main content

No project description provided

Project description

nginxsitepy

A command-line tool for managing Nginx site configurations with location-based operations.

Features

  • Easy Location Management: Add, delete, and modify Nginx location blocks
  • Directive Management: Add directives to specific locations while preserving order
  • State Persistence: Remember configuration file settings between commands
  • Clean Formatting: Maintain proper indentation and avoid unnecessary blank lines
  • Safe Operations: Backup and validate configurations before changes

Installation

pip install nginxsitepy

Quick Start

  1. Set your Nginx configuration file:
nginx-sites set_config /etc/nginx/sites-enabled/default
  1. Add a location block:
nginx-sites add /api
  1. Add directives to a location:
nginx-sites directive /api "proxy_pass http://localhost:3000"
nginx-sites directive /api "proxy_set_header Host \$host"
  1. View your configuration:
nginx-sites summary

Commands

Configuration Management

  • nginx-sites set_config <file> - Set the Nginx configuration file to work with
  • nginx-sites status - Show current configuration status
  • nginx-sites clear - Clear saved state

Location Operations

  • nginx-sites list - List all location blocks
  • nginx-sites show <path> - Show details of a specific location
  • nginx-sites add <path> [directive] - Add a new location block (optionally with a directive)
  • nginx-sites delete <path> - Delete a location block

Directive Management

  • nginx-sites directive <path> <directive> - Add a directive to a location block

Information

  • nginx-sites summary - Show a complete summary of all locations and directives

Examples

Basic Flask Application Setup

# Set configuration file
nginx-sites set_config /etc/nginx/sites-enabled/default

# Add main location
nginx-sites add /
nginx-sites directive / "try_files \$uri @flask_application"

# Add Flask upstream location
nginx-sites add @flask_application
nginx-sites directive @flask_application "proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for"
nginx-sites directive @flask_application "proxy_set_header X-Forwarded-Proto \$scheme"
nginx-sites directive @flask_application "proxy_set_header Host \$http_host"
nginx-sites directive @flask_application "proxy_redirect off"
nginx-sites directive @flask_application "proxy_pass http://localhost:8000"

API Gateway Setup

# API endpoints
nginx-sites add /api/v1
nginx-sites directive /api/v1 "proxy_pass http://api-server:3000"

nginx-sites add /api/v2
nginx-sites directive /api/v2 "proxy_pass http://api-server-v2:3001"

# Static files
nginx-sites add /static
nginx-sites directive /static "root /var/www"
nginx-sites directive /static "expires 30d"

View Configuration

# List all locations
nginx-sites list

# Show specific location
nginx-sites show /api/v1

# Complete summary
nginx-sites summary

Options

  • --server, -s INDEX - Specify server block index (default: 0)

Example:

nginx-sites --server 1 list
nginx-sites -s 1 directive / "root /var/www/site2"

Requirements

  • Python 3.9+
  • Read/write access to Nginx configuration files

Development

Clone the repository:

git clone <repository-url>
cd nginxsitepy

Install in development mode:

pip install -e .

License

MIT License

Author

ji-ho lee (search5@gmail.com)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Changelog

0.1.0

  • Initial release
  • Basic location and directive management
  • State persistence
  • Clean formatting and indentation preservation

Project details


Download files

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

Source Distribution

nginxsitepy-0.1.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

nginxsitepy-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file nginxsitepy-0.1.0.tar.gz.

File metadata

  • Download URL: nginxsitepy-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.12 Linux/6.8.0-60-generic

File hashes

Hashes for nginxsitepy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5b09e40fcb23b5934977aadb3dba45cfc9f86588c480337f724036b1465f765e
MD5 f306bc73b2556715aab1d6607a6e3c9e
BLAKE2b-256 43e51e1866453afe2af638026f24a6ecbe479f1b88996313fb4e33a82ebe187f

See more details on using hashes here.

File details

Details for the file nginxsitepy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nginxsitepy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.12 Linux/6.8.0-60-generic

File hashes

Hashes for nginxsitepy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b604053a8ea9192575b8cf93b6073ce38c348abb92cb1bf87b786332c44496e
MD5 1ef594c0325f3f1a1f05335e7f0143ae
BLAKE2b-256 9aceb639bbd7b1257570b419a3036399ed1481e1d263e52b6c97b79b690eafd2

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