Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binocarlos/nginx-vhost
A bash script to make Nginx HTTP proxies to backend nodes
https://github.com/binocarlos/nginx-vhost
Last synced: 10 days ago
JSON representation
A bash script to make Nginx HTTP proxies to backend nodes
- Host: GitHub
- URL: https://github.com/binocarlos/nginx-vhost
- Owner: binocarlos
- License: mit
- Created: 2013-12-21T16:44:44.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-02-16T18:27:51.000Z (almost 11 years ago)
- Last Synced: 2024-04-14T14:36:44.657Z (7 months ago)
- Language: Shell
- Size: 203 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
nginx-vhost
===========![Build status](https://api.travis-ci.org/binocarlos/nginx-vhost.png)
A bash script wrapper for nginx that makes it easy load balance HTTP to multiple backend app servers.
```
INTERNET
|
|
PUBLIC_IP:80 (nginx)
/ | \
/ | \
www1 www2 www3
```It works by managing /etc/nginx/conf.d/*.conf vhost files and sudo restart permissions.
## example
This example will setup 2 websites.
The first has a static folder and the other is load-balanced to 2 different backend servers.
```bash
#!/usr/bin/env bash# first setup the static website
nginx-vhost domains staticapp static.myapp.com
nginx-vhost document_root staticapp /srv/projects/app/static/www# now the proxied app
nginx-vhost domains app myapp.com *.myapp.com
nginx-vhost backends app 127.0.0.1:8791 127.0.0.1:8792# then apply what we have done
nginx-vhost apply
```## installation
```
$ wget -qO- https://raw.github.com/binocarlos/nginx-vhost/master/bootstrap.sh | sudo bash
```As part of your installation script - you can use the 'adduser' command.
```
admin@localhost$ sudo nginx-vhost adduser myuser
```myuser is now able to call 'nginx-vhost apply' and 'nginx-vhost reload' - the group permissions are allocated
so that myuser can restart nginx.## usage
### useradd
use this command in your installation script to allow the given username use the 'nginx-vhost' command.
```
$ sudo nginx-vhost useradd git
```this command should be run once and as root
### domains
set the domains for a given app id
```
$ nginx-vhost domains myapp myapp.com *.myapp.com
```### backends []
set the backend routes for a given app id
```
$ nginx-vhost backends myapp 127.0.0.1:7463 127.0.0.1:7464
```### document_root
for static websites set the document_root for a given app id
```
$ nginx-vhost document_root myapp /srv/projects/myapp/www
```### ssl_cert
set the SSL certificate for the given app
```
$ nginx-vhost document_root myapp /srv/projects/ssl/myapp/cert.pem
```### ssl_key
set the SSL key for the given app
```
$ nginx-vhost document_root myapp /srv/projects/ssl/myapp/key.pem
```### remove
remove a given app id
```
$ nginx-vhost remove myapp
```### apply
writes out the nginx config files and restarts the server
call this once you have applied your setup
```
$ nginx-vhost apply
```## License
MIT