···50505151Most commands require sudo to modify Nginx directories and reload the service.
52525353-- List sites: sudo nx list (or nx l)
5454-- Enable site: sudo nx enable mydomain.com
5555-- Disable site: sudo nx disable mydomain.com
5656-- Edit config: sudo nx e mydomain.com
5757-- Print config: nx p mydomain.com
5858-5953```bash
6054NX - Nginx Site Manager
6155···6559 nx <command> [arguments]
66606761COMMANDS:
6868- list, l List all sites. Supports --enabled or --available filters.
6969- enable <site> Enable a site by creating a symlink.
7070- disable <site> Disable a site by removing the symlink.
7171- edit, e <site> Open site config in $EDITOR.
7272- cat, print, p <site> Preview site config using batcat or cat.
6262+ list, l List all sites. Supports --enabled or --available filters.
6363+ enable <site> Enable a site by creating a symlink.
6464+ disable <site> Disable a site by removing the symlink.
6565+ edit, e <site> Open site config in $EDITOR.
6666+ cat, print, p <site> Preview site config using batcat or cat.
73677468EXAMPLES:
7569 sudo nx list
7676- sudo nx enable mydomain.com
7777- sudo nx e mydomain.com
7070+ sudo nx enable example.com
7171+ sudo nx disable pds.example.com
7272+ sudo nx e example.com
7373+ sudo nx print knot.example.com
78747975ENVIRONMENT:
8080- $EDITOR: Currently set to nano
7676+ EDITOR Currently set to nano
7777+ NX_SITES_AVAILABLE_PATH Currently set to /etc/nginx/sites-available
7878+ NX_SITES_ENABLED_PATH Currently set to /etc/nginx/sites-enabled
8179```
82808381## Environment Variables
84828583The edit command respects your preferred editor. You can set this in your ~/.bashrc or ~/.zshrc:
86848585+```bash
8786export EDITOR='emacs'
8787+```
88888989-Note: To ensure your personal $EDITOR setting is picked up when running with sudo, use the -E flag:
9090-sudo -E nx e mydomain.com
8989+Alternative sites-available and sites-enabled directories can be configured using the following
9090+environment variables.
9191+9292+```bash
9393+export NX_SITES_AVAILABLE_PATH=<preferred-path>
9494+export NX_SITES_ENABLED_PATH=<preferred-path>
9595+```
9696+9797+Note: To ensure your environment variables are picked up when running with sudo, use the -E flag:
9898+9999+```bash
100100+sudo -E nx enable example.com
101101+```
9110292103## License
93104
+7-5
nx
···11#!/bin/bash
2233# Configuration
44-AVAILABLE="/etc/nginx/sites-available"
55-ENABLED="/etc/nginx/sites-enabled"
44+AVAILABLE=${NX_SITES_AVAILABLE_PATH:-/etc/nginx/sites-available}
55+ENABLED=${NX_SITES_ENABLED_PATH:-/etc/nginx/sites-enabled}
66ACTION=$1
77SITE=$2
88···140140141141${BOLD}EXAMPLES:${NC}
142142 sudo nx list
143143- sudo nx enable mydomain.com
144144- sudo nx e mydomain.com
143143+ sudo nx enable example.com
144144+ sudo nx e example.com
145145146146${BOLD}ENVIRONMENT:${NC}
147147- \$EDITOR: Currently set to ${BOLD}${EDITOR:-nano}${NC}
147147+ EDITOR Currently set to ${BOLD}${EDITOR:-nano}${NC}
148148+ NX_SITES_AVAILABLE_PATH Currently set to ${BOLD}${AVAILABLE}${NC}
149149+ NX_SITES_ENABLED_PATH Currently set to ${BOLD}${ENABLED}${NC}
148150EOF
149151)"
150152 exit 1