https://github.com/grimen/nginx-sandbox
Nginx/OpenResty sandbox/playground - for experiments with building Nginx apps using Lua.
https://github.com/grimen/nginx-sandbox
Last synced: 11 months ago
JSON representation
Nginx/OpenResty sandbox/playground - for experiments with building Nginx apps using Lua.
- Host: GitHub
- URL: https://github.com/grimen/nginx-sandbox
- Owner: grimen
- Created: 2012-07-17T03:28:26.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2013-12-14T17:56:06.000Z (over 12 years ago)
- Last Synced: 2025-05-03T19:39:02.278Z (about 1 year ago)
- Language: Shell
- Homepage:
- Size: 307 KB
- Stars: 11
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NGINX-SANDBOX
_[`Nginx/OpenResty`](http://openresty.org) sandbox/playground - for experiments with building [`Nginx`](http://nginx.org) apps using [`Lua`](http://lua.org)._

## Features
The build script will install local/sandboxed versions of:
* `ngx_openresty`
* `lua` - via openresty
* `pcre`
* `zlib`
* `openssl`
* `luarocks` - optional
The default Nginx setup contains mainly:
* Default Nginx configs - with comments/documentation
* Example code:
* Lua basic demo
* Lua/LuaRocks module demo
* Lua/WebSockets ping/pong demo - incl. client HTML page
* Lua/Redis read/write demo
* Vagrant prototypes
* Docker prototypes
## Build
**Sandboxed Nginx/OpenResty:**
```bash
nginx-sandbox$ make build
```
...this will take a while because all dependencies (`pcre`, `openssl`, `zlib`, ...) are being compiled into sandbox as well (`./vendor/*`) for isolation reasons.
## Run Nginx
If `nginx.conf` contains directive `daemon off;`.
**Start Nginx/OpenResty:**
```bash
nginx-sandbox$ make start
```
**Ta-ta!**
```bash
nginx-sandbox$ open http://localhost:8080
```
*"- Is this live? - Yes this is live. On localhost."*
**Stop Nginx/OpenResty:**
`CTRL + C` / `SIGINT`
## Run Nginx as daemon
If `nginx.conf` contains directive `daemon on;`.
**Start/Restart Nginx:**
```bash
nginx-sandbox$ make start
```
**Ta-ta!**
```bash
nginx-sandbox$ open http://localhost:8080
```
**Stop Nginx/OpenResty:**
```bash
nginx-sandbox$ make stop
```
## Run Nginx as Docker container in Vagrant box
**Provision Nginx using Vagrant and Docker:**
```bash
nginx-sandbox$ vagrant up
nginx-sandbox$ vagrant provision
```
**Check status from inside:**
```bash
nginx-sandbox$ vagrant ssh
vagrant@ubuntu$ docker ps
vagrant@ubuntu$ docker inspect nginx
vagrant@ubuntu$ curl http://localhost:80
```
**Check status from outside:**
```bash
vagrant@ubuntu$ exit
nginx-sandbox$ curl http://localhost:8080
```
## Advanced: Install additional Lua modules
Install additional local/sandboxed *Lua modules* via local/sandboxed [`LuaRocks`](http://luarocks.org):
```bash
nginx-sandbox$ make luarocks install md5
...
nginx-sandbox$ make luarocks list
...
```
*NOTE: `make luarocks` is passing any succeding arguments to the sandboxed `luarocks` binary, so all arguments that work with the original will work here too.*
## Notes
The build scripts may contain *OS X only* operations. Should be simple to port it to POSIX though.
Find development notes in [`NOTES`](https://github.com/grimen/nginx-sandbox/blob/master/NOTES).
## Todo
See [`TODO`](https://github.com/grimen/nginx-sandbox/blob/master/TODO).
## License
Released under the MIT license. Copyright © [Jonas Grimfelt](https://github.com/grimen)
[](https://bitdeli.com/free "Bitdeli Badge")