Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eatonphil/vhostm
Manage nginx virtual servers and hosts file entries
https://github.com/eatonphil/vhostm
Last synced: 20 days ago
JSON representation
Manage nginx virtual servers and hosts file entries
- Host: GitHub
- URL: https://github.com/eatonphil/vhostm
- Owner: eatonphil
- License: mit
- Created: 2015-09-22T00:48:14.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-21T18:05:17.000Z (almost 7 years ago)
- Last Synced: 2024-10-16T22:10:06.436Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 18.6 KB
- Stars: 105
- Watchers: 8
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# vhostm
This python3 script facilitates the creation and deletion of nginx virtual servers
and hosts file entries.### Motivation
It is annoying to set up new virtual servers and hosts file entries by hand
every time I take on a new client.## Install
### To install from pypi
```bash
sudo pip install vhostm
```### To install for development
```bash
git clone [email protected]:eatonphil/vhostm
cd vhostm
pyvenv .env
. .env/bin/activate
pip install -e ./
```## Usage
Vhostm differs slightly from spinup and provides a much more useful interface
for viewing existing vhosts.### Setup
The following defaults are used:
```json
{
"nginx_conf_dir": "/etc/nginx/sites-enabled",
"hosts_file": "/etc/hosts",
"vhosts_file": "/etc/vhostm/vhosts.conf"
}
```To override any of these settings per user, copy the json with the settings
you wish to override into ~/.vhostm.conf and change the value of the key.For instance, on FreeBSD, the config (~/.vhostm.conf) may look like this:
```json
{
"nginx_conf_dir": "/usr/local/etc/nginx/conf.d",
"vhosts_file": "/usr/local/etc/vhostm/vhosts.conf"
}
```You may also override either of these per command by using the flags
(--nginx_conf_dir, --vhosts_file, --hosts_file).### List
```bash
sudo vhostm list
```### Create
This one-liner creates a new vhost at `/etc/nginx/sites-enabled/mysite.com`
that forwards mysite.com to localhost:3000 and serves static files from
./static. Additionally, this adds an entry in your hosts file so mysite.com
points to localhost.```bash
sudo vhostm add -d mysite.com -p 3000 -s ./static
```### Delete
This one-line deletes the previously created config file and removes the
entry from the hosts file.```bash
sudo vhostm del -d mysite.com
```## Alternative template file
If you would like to provide an alternative template for the nginx
config, you can override the default by using the --nginx_template_file
flag or assigning the "nginx_template_file" in the ~/.vhostm.conf file.Use the default template in vhostm/vhostm.py as an example.