1.0.6 • Published 6 years ago

ngnx v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

ngnx

A simple command-line interface for running and managing nginx on a server, either from the server's shell, or from any shell using SSH.

Coming Soon

This is a project by Mike Turley. ... it's still being developed.

He just really wanted the package name... he'll finish it eventually.

CLI

~$ ngnx

Examples

Non-"connected" mode, or script mode:

ngnx mydomain.com setup

  # Prompt for ssh credentials if ssh-agent doesn't have them
  # Current status of ngnx on the host
  # What will setup do to your machine if you continue
  # Whether you want to use sudo and what that means
  # Ready? [y/N]

ngnx mydomain.com sites

  # Returns a list of the files in /etc/nginx/sites-available, with enabled status,
  # some critical config flags from each one, and any status info we can get from nginx -t.

ngnx mydomain.com status      # sudo service nginx status
ngnx mydomain.com start       # sudo service nginx start
ngnx mydomain.com stop        # sudo service nginx stop
ngnx mydomain.com restart     # sudo service nginx restart
ngnx mydomain.com reload      # sudo nginx -s reload
ngnx mydomain.com test        # sudo nginx -t

ngnx mydomain.com create-site myawesomesite    # Create an nginx config file in /etc/nginx/sites-available
ngnx mydomain.com site myawesomesite info      # Show: path to config file, enabled status, other info from nginx -t
ngnx mydomain.com site myawesomesite enable    # Symlink the config file into /etc/nginx/sites-enabled
ngnx mydomain.com site myawesomesite disable   # Remove the symlink
ngnx mydomain.com site myawesomesite edit      # Parse and edit the config file in a simple fashion
ngnx mydomain.com site myawesomesite rename    # Rename the config file
ngnx mydomain.com site myawesomesite remove    # Remove the config file (saving a backup just in case).

"Connected" mode, makes for shorter commands if you are working on one host for a while. You are not actually maintaining an open connection, this is just a way to locally store some repetitive parts of the above commands and alias them, with some context info being logged to tell you what mode you're in.

There is a little more overhead in connecting to SSH on each command this way, but it makes all operations atomic and removes the problem of what happens when you lose your internet connection (you just try the last command again later). Options for a persistent SSH connection are not a goal for ngnx, because it works locally too, so you should just ssh to the server and run ngnx localhost commands there if you want one connection.

As far as the user can see, however, they are in a shell on that server controlling its nginx sites. But in this context, "being connected" means you have recently checked that you can successfully run commands on a server and that server is remembered for commands while connected.

ngnx connect mydomain.com

# [ngnx] checking mydomain.com connectivity and permissions...
# [ngnx@mydomain.com] connected

# Commands from above are shorter now:
ngnx setup
ngnx sites
ngnx status
ngnx start
ngnx stop
ngnx restart
ngnx reload
ngnx test
ngnx create-site myawesomesite
ngnx site myawesomesite info
ngnx site myawesomesite enable
ngnx site myawesomesite disable
ngnx site myawesomesite edit
ngnx site myawesomesite rename
ngnx site myawesomesite remove

# You can even select a site to make them even shorter:
ngnx select myawesomesite

# [ngnx@mydomain.com:myawesomesite] site selected

# Thanks to a lack of name collisions, site commands become super short:
ngnx info
ngnx enable
ngnx disable
ngnx edit
ngnx rename
ngnx remove

# When you're done, just:
ngnx deselect

# [ngnx@mydomain.com] deselected myawesomesite

ngnx disconnect

# [ngnx] disconnected from mydomain.com

# or, you can just `ngnx disconnect` at any time to leave any connections or selections behind.

ngnx disconnect

# [ngnx@mydomain.com] deselected myawesomesite
# [ngnx] disconnected from mydomain.com

Connect directly to a site

There is a shorthand for ngnx connect mydomain.com followed by ngnx select myawesomesite:

ngnx connect mydomain.com:myawesomesite

This takes you straight to the [ngnx@mydomain.com:myawesomesite] mode, where you can jump straight to the shortest form of each command:

ngnx setup
ngnx sites
ngnx status
ngnx start
ngnx stop
ngnx restart
ngnx reload
ngnx test
ngnx info
ngnx enable
ngnx disable
ngnx edit
ngnx rename
ngnx remove
ngnx select someothersite
ngnx deselect
ngnx disconnect

If that is not the cleanest way to manage a web server remotely, I don't know what is.

Local mode

If given the special string localhost instead of something like mydomain.com or an IP address, ngnx will try to operate on a local nginx server directly without using SSH.

ngnx localhost create-site testingsite

# Or:
ngnx connect localhost
ngnx create-site testingsite
ngnx disconnect
1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago