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
- Set your Nginx configuration file:
nginx-sites set_config /etc/nginx/sites-enabled/default
- Add a location block:
nginx-sites add /api
- Add directives to a location:
nginx-sites directive /api "proxy_pass http://localhost:3000"
nginx-sites directive /api "proxy_set_header Host \$host"
- View your configuration:
nginx-sites summary
Commands
Configuration Management
nginx-sites set_config <file>- Set the Nginx configuration file to work withnginx-sites status- Show current configuration statusnginx-sites clear- Clear saved state
Location Operations
nginx-sites list- List all location blocksnginx-sites show <path>- Show details of a specific locationnginx-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
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Changelog
0.1.0
- Initial release
- Basic location and directive management
- State persistence
- Clean formatting and indentation preservation
Metadata
Release files for nginxsitepy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nginxsitepy-0.1.0.tar.gz | 8.9 kB | Without provenance | Details for nginxsitepy-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nginxsitepy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nginxsitepy-0.1.0-py3-none-any.whl |
Total release size: 17.6 kB
Release files / nginxsitepy-0.1.0.tar.gz
| Download URL | nginxsitepy-0.1.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b09e40fcb23b5934977aadb3dba45cfc9f86588c480337f724036b1465f765e
|
|
BLAKE2b-256 checksum How to use checksums |
43e51e1866453afe2af638026f24a6ecbe479f1b88996313fb4e33a82ebe187f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.10.12 Linux/6.8.0-60-generic
|
Release files / nginxsitepy-0.1.0-py3-none-any.whl
| Download URL | nginxsitepy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9b604053a8ea9192575b8cf93b6073ce38c348abb92cb1bf87b786332c44496e
|
|
BLAKE2b-256 checksum How to use checksums |
9aceb639bbd7b1257570b419a3036399ed1481e1d263e52b6c97b79b690eafd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.10.12 Linux/6.8.0-60-generic
|
Security for nginxsitepy 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.