Replicate Kubernetes Ingress on Docker Compose stack

DevOps Aug 17, 2021

Exposing a container service to outside is often not easy. Especially when considering the SSL certifications. To address this problem, Kubernetes introduced a concept called Ingress, in which provides routing from the outside of the cluster to services within the container[1].

Traditionally, there are mainly three methods of exposing the service to the internet. The simplest way is to expose the port to the host directly, then it will be able to accessed via <hostip>:<port>. Another method is to use a reverse proxy on the host, mapping the services with a domain. The last is similar to the second but instead deploying the reverse proxy using another container.

The second method is basically the extends of the first method. The last method however, should be recommended since it uses the container's hostname for addressing. Which adds more flexibility.

In this article, we will introduce a method similar to the last method mentioned above but includes some GUI tools for easier management.


  1. https://kubernetes.io/docs/concepts/services-networking/ingress/ ↩︎

Nginx Proxy Manager (npm but not)

Nginx Proxy Manager
Docker container and built in Web Application for managing Nginx proxy hosts with a simple, powerful interface, providing free SSL support via Let’s Encrypt

NPM provides functionalities such as proxying the services, acquiring Letsencrypt certifications automatically, etc. We are going to use this service to mimic the Kubernetes Ingress.

After installation, if by following the setup guide, the service will be available under port 81.

It should be noted that NPM doesn't support MySQL version 8.x.  A workaround for this is to use sqlite as database.

Proxying the service

Add new proxy host in NPM

The configuration is rather simple, given to the example above. SSL certifications could be enabled from the SSL tab. With options of uploading certification manually or acquire new certification from Letsencrypt. This should be useful for exposing the service to public.

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.