Ngonx
It`s a simple proxy server written with go.
The core services are based on nginx server, and traefik
ngonx commands
Build
make compile
List of command available
ngonxctl -h
This is Ngonx ctl a proxy reverse inspired on nginx & traefik
Usage:
ngonxctl [command]
Available Commands:
completion generate the autocompletion script for the specified shell
help Help about any command
lb Run ngonx as a load balancer (round robin)
proxy Run ngonx as a reverse proxy
setup Create configuration file it`s doesn`t exist
static Run ngonx as a static web server
version Print the version number of ngonxctl
Flags:
-f, --cfgfile string File setting.yml (default "ngonx.yaml")
-p, --cfgpath string Config path only (default "path/binary")
-h, --help help for ngonxctl
Use "ngonxctl [command] --help" for more information about a command.
Start Proxy server first time
genkey
command in true generate random secretkey and save on badgerdb on badger.data
./ngonxctl proxy -port 5000 -genkey true
prevkey
command receive a custom secretkey and save this on badgerdb on badger.data
./ngonxctl proxy -port 5000 -prevkey <secretKey>
Start Proxy server
./ngonxctl proxy -port 5000
Start load balancer
./ngonxctl lb --backends "http://localhost:5000,http://localhost:5001,http://localhost:5002"
Start static files server
./ngonxctl static
Metrics
Currently ngonx use prometheus as a metric collector. The main service proxy
expose for port 10000 on route /metrics
curl http://localhost:10000/metrics
Management API & Web(coming...)
Currently ngonx use port 10001 for export a simple api to check all services
curl http://localhost:10001/api/v1/mngt/
Start API PoC service
go run services/micro-a/api.go --port <port>
Install badger db on window if you don`t use CGO
CGO_ENABLED=0 go get github.com/dgraph-io/badger/v3
Generate customs SSL (key,cert,pem,crs,cnf)
cd scripts
chmod +x ./generate.sh
./generate.sh
Generate SSL (throug let`s encrypt)
Check this post "Contratar un certificado SSL Gratis con Let's Encrypt y configurar Nginx" by @acoronado for more information.
apt-get install -y certbot
certbot certonly \
-d midominio.com \
--noninteractive \
--standalone \
--agree-tos \
--register-unsafely-without-email
Then configure our ngonx.yaml
and add the ssl files generated by certbot
# For SSL static server
ssl_server:
enable: true
ssl_port: 8443
crt_file: /etc/letsencrypt/live/mydomain.com/fullchain.pem
key_file: /etc/letsencrypt/live/mydomain.com/privkey.pem
# For SSL proxy server
ssl_proxy:
enable: true
ssl_port: 443
crt_file: /etc/letsencrypt/live/mydomain.com/fullchain.pem
key_file: /etc/letsencrypt/live/mydomain.com/privkey.pem
When the ssl certification was expired you need to renew all certificates
with the following commnad
certbot renew
BenchMarking
ab -c 1000 -n 10000 http://localhost:<proxyPort>/health