Skip to content

Cross platform Go lang implementation of NGINX functionality with SSL management, static file serving, and HTTP reverse proxy to Python, Node, Rails or other http web service

License

dioptre/dragongate

 
 

Repository files navigation

DragonGate

A pure Go lang replacement for NGINX in one page of code with proxying, file server, benchmarks, templates and automatic TLS support using LetsEncrypt (or normal certificates or using AWS ECS secure parameters). A docker deployment option is also mentioned below.

Instructions

Setup

  • Install go and dependencies, requires Go +1.8 (on debian buster):
apt install golang-1.8-go git libssl-dev
  • Add the following to your ~/.bashrc:
export GOROOT=/usr/lib/go-1.8
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
  • Get, build and run the sources (change the config.json to your liking):
go get github.com/dioptre/dragongate
cd ~/go/src/github.com/dioptre/dragongate
go install
./debug.sh
  • You may want to change the config.json
{
    "Domains": ["dev.sfproductlabs.com"],
    "ProxyUrl": "http://localhost:8000",
    "StaticDirectory" : "public",
    "UsePingPong" : true,
    "UseLocalTLS" : false
}
  • Domains is required and is what domains are allowed, and connect automatically to LetsEncrypt.
  • ProxyUrl (optional) if included proxies connections to a Node.js or other local web service.
  • StaticDirectory (optional) if included serves static files from this subdirectory
  • UsePingPong (optional) if included responds "pong" to https://yourdomain.com/ping
  • UseLocalTLS (optional) if included and true elects to use server.crt, and server.key instead of LetsEncrypt.

Troubleshooting

I had to disable ipv6 (error during LetsEncrypt init phase) also, this has been done in the docker image also.

  • Edit /etc/sysctl.conf:
net.ipv6.conf.enp6s0.disable_ipv6 = 1

Tests

  • Tested on ARM and x64.

  • Benchmarking run:

./benchmark.sh https://yourservername.com/ping

My results are around 1,000 requests per second per $ per server per month (@dioptre).

  • Run a test server to proxy to:
./proxy_server.sh
  • Test key (outside of LetsEncrypt)
# You can also use the helper genkey.sh
openssl ecparam -genkey -name secp384r1 -out server.key
openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650

Deploy

# Build from src:
sudo docker build -t dragongate .
# Deploy only:
# sudo docker build -f Dockerfile.deploy -t dragongate .
sudo docker run -p 8443:443 dragongate
# Connect to it:
#  sudo docker ps
#  sudo docker exec -it [container_id] bash
# Remove all your images (warning):
#  sudo docker system prune -a
  • Then upload/use (try AWS ECS).

Credits

About

Cross platform Go lang implementation of NGINX functionality with SSL management, static file serving, and HTTP reverse proxy to Python, Node, Rails or other http web service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 60.6%
  • Dockerfile 25.6%
  • Shell 12.5%
  • HTML 1.3%