A simple utility to manage Nginx configurations.

Update README

+52 -9
+52 -9
README.md
··· 1 1 # NX - Nginx Site Manager 2 2 3 - A lightweight, colorized Bash utility to manage Nginx virtual hosts using the sites-available / sites-enabled pattern. 3 + A lightweight, colorized Bash utility to manage Nginx virtual hosts using the `sites-available` / `sites-enabled` pattern. 4 4 5 - It replaces the need for manual ln -s and rm commands with a simple, human-readable interface. 5 + It replaces the need for manual `ln -s` and `rm` commands with a simple, human-readable interface. 6 6 7 7 ## Features 8 8 9 9 * Tree-view Listing: Automatically groups subdomains under their parent domains using ASCII logic. 10 + ``` 11 + $ sudo nx list 12 + SITE STATUS 13 + ---------------------------------------- ---------- 14 + example.com Enabled 15 + └── knot.example.com Enabled 16 + └── pds.example.com Enabled 17 + └── statusphere.example.com Enabled 18 + default Disabled 19 + example.net Enabled 20 + └── staging.example.net Enabled 21 + └── wiki.example.net Disabled 22 + └── ws.example.net Disabled 23 + ``` 10 24 * Status Indicators: Color-coded feedback for "Enabled" (Green) and "Disabled" sites. 11 25 * Smart Suffixes: Automatically handles .conf extensions so you don't have to type them. 12 26 * Integrated Testing: Prompts to run nginx -t and reload the service after every edit or toggle. 13 27 * Config Preview: Uses batcat (with syntax highlighting) if installed, otherwise falls back to cat. 28 + ```bash 29 + $ sudo nx print knot.example.com 30 + ───────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 31 + │ File: /etc/nginx/sites-available/knot.example.com.conf 32 + ───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 33 + 1 │ server { 34 + 2 │ listen 443 ssl; 35 + 3 │ listen [::]:443 ssl; 36 + 4 │ server_name knot.example.com; 37 + 5 │ 38 + 6 │ ssl_certificate /etc/ssl/acme/example.com/fullchain.pem; 39 + 7 │ ssl_certificate_key /etc/ssl/acme/example.com/key.pem; 40 + 8 │ 41 + 9 │ access_log /var/log/nginx/example.access.log main; 42 + 10 │ 43 + 11 │ location / { 44 + 12 │ proxy_pass http://127.0.0.1:5555; 45 + 13 │ proxy_http_version 1.1; 46 + 14 │ 47 + 15 │ proxy_set_header Upgrade $http_upgrade; 48 + 16 │ proxy_set_header Connection $connection_upgrade; 49 + 17 │ 50 + 18 │ proxy_set_header Host $host; 51 + 19 │ proxy_set_header X-Real-IP $remote_addr; 52 + 20 │ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 53 + 21 │ proxy_set_header X-Forwarded-Proto $scheme; 54 + 22 │ } 55 + 23 │ } 56 + ───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 57 + ``` 14 58 15 59 ## Installation 16 60 ··· 36 80 4. Ensure that your main Nginx config (e.g., `/etc/nginx/nginx.conf`) attempts to load in configurations 37 81 at `/etc/nginx/sites-enabled/*` (or wherever you'd like to store your configurations). 38 82 39 - For example, your `/etc/nginx/nginx.conf` should contain the following: 40 - ```conf 41 - # ... 83 + ```conf 84 + # ... 42 85 43 - http { 44 - # ... 86 + http { 87 + # ... 45 88 include /etc/nginx/sites-enabled/*; 46 - } 47 - ``` 89 + } 90 + ``` 48 91 49 92 ## Usage 50 93