Skip to content

💎 This is an example of FastContainer implementation by nginx, ngx_mruby and haconiwa.

License

Notifications You must be signed in to change notification settings

FastContainer/nginx-haconiwa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastContainer: Nginx with Haconiwa

This is an example of FastContainer implementation by nginx, ngx_mruby and haconiwa.

overview

Requirement

  • docker >= 18.06.0-ce
  • vagrant >= 2.1.1

Usage

To create an image to use in this implementation, run GNU make and vagrant to run the VM on the Virtualbox.

# Create nginx and container images to `./provision/dist`
$ make

# Create instance, and provision by `./provision/provisioner.sh`
$ vagrant up

When the VM starts up, let's start the container with the request trigger in the following way.

HTTP

HTTP container starts

$ curl https://127.0.0.1:8080/

# HTTP foo container responds
$ curl -H 'Host: foo.test' https://127.0.0.1:8080/

# HTTP bar container responds
$ curl -H 'Host: bar.test' https://127.0.0.1:8080/

SSH

SSH container starts

$ ssh [email protected] -p 8022
# => password: screencast

SMTP

SMTP container starts

$ printf "%s\0%s\0%s" foo foo password | openssl base64 -e
Zm9vAGZvbwBwYXNzd29yZA==

$ telnet 127.0.0.1 8025
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 ubuntu-xenial ESMTP ready
HELO local
250 ubuntu-xenial
AUTH PLAIN Zm9vAGZvbwBwYXNzd29yZA==
235 2.0.0 OK
# SMTP foo container responds

$ printf "%s\0%s\0%s" bar bar password | openssl base64 -e
YmFyAGJhcgBwYXNzd29yZA==

$ telnet 127.0.0.1 8025
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 ubuntu-xenial ESMTP ready
HELO local
250 ubuntu-xenial
AUTH PLAIN YmFyAGJhcgBwYXNzd29yZA==
235 2.0.0 OK
# SMTP bar container responds

Multitenancy

HTTP determines the domain from the request host and SMTP determines the domain from SMTP AUTH. Then, upstream containers are dynamically selected from the discrimination.

multitenancy

SMTP AUTH uses ngx_mail_core_module.

Todo

  • Multitenancy
  • Auto Scaling
  • Multi Host

Author

License

This project is under the MIT License.