Subdomains on a coreOS system

By | January 12, 2018
Questions:

I am looking into using docker to run a view different development environments.

I want to port those environments out to various subdomains using server blocks with nginx.

Is it possible to set up server blocks on a CoreOS system? I am under the impression that all environments you set up must be a docker container, I was unsure how this would work if I wanted to set up all my subdomains for one instance of nginx when this instance would have to run standalone in a dockerized container.

Would I be better to set up something like ubuntu nginx installed at the base and then individual docker instances in each server block (subdomain) folder.

Answers:

Yes, this is absolutely possible. It involves two steps:

  1. Service discovery for the docker containers that make up your development environments. This means writing their IP:port combo into etcd when the containers are started.
    This blog post goes into detail on the service registration part of it: http://coreos.com/blog/zero-downtime-frontend-deploys-vulcand/

  2. Using confd to dynamically write out your nginx config. Confd will read from etcd and use a loop to set up your server blocks. Nginx will then be reloaded to apply the new settings.
    You can see this all put together in this blog post: http://marceldegraaf.net/2014/04/24/experimenting-with-coreos-confd-etcd-fleet-and-cloudformation.html

Confd Github:
https://github.com/kelseyhightower/confd

Leave a Reply

Your email address will not be published. Required fields are marked *