Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mafintosh/taco-nginx
Bash script that runs a service and forwards a subdomain to it using nginx when it listens to $PORT
https://github.com/mafintosh/taco-nginx
Last synced: 11 days ago
JSON representation
Bash script that runs a service and forwards a subdomain to it using nginx when it listens to $PORT
- Host: GitHub
- URL: https://github.com/mafintosh/taco-nginx
- Owner: mafintosh
- License: mit
- Created: 2015-04-19T19:38:43.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-01-26T16:21:01.000Z (almost 6 years ago)
- Last Synced: 2024-10-29T11:13:05.635Z (14 days ago)
- Language: Shell
- Size: 22.5 KB
- Stars: 101
- Watchers: 5
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# taco-nginx
Bash script that runs a service and forwards a subdomain to it using nginx when it listens to `$PORT`
```
npm install -g taco-nginx
```We recommend using latest stable nginx (>1.8.0). If you are on Ubuntu LTS for example you may need to do this:
```
add-apt-repository ppa:nginx/stable
apt-get update
apt-get install nginx
```## Usage
First write a service (in any language) similar to this
``` js
var http = require('http')
var server = http.createServer(function (req, res) {
console.log('Got request!', req.url)
res.end('hello world\n')
})server.listen(process.env.PORT, function () {
console.log('Server is listening...')
})
```Assuming the above file is called `server.js` and you have `nginx` running you can now do
``` sh
taco-nginx --name my-service node server.js
```taco-nginx will now spawn `node server.js`, wait for it to listen to the port specified in
`$PORT` and then have nginx route requests to `my-service.*` to it.If you don't specify `--name` it will see if you have a `package.json` and use the name field
``` sh
taco-nginx node server.js # uses name from package.json
```For a full list of options run
```
taco-nginx --help
```## License
MIT