Giter Club home page Giter Club logo

tugboat's Introduction

Tugboat, automatic NGINX reverse proxy for containers

This project contains a NGINX reverse proxy, consul, and registrator. When used together, they can create dynamic virtual host for any web container you launch.

This project requires that you are using the Docker Toolbox, which uses docker-machine with Virtualbox and Boot2Docker. It will not work on linux (unless you manually set a host IP of 192.168.99.100).

This means every new container (when lightly configured) you launch, will have a custom hostname you can pull up in your browser.

Yes. Really.

asciicast

How to run:

  1. Clone this repo.
  2. Run make start

How to get your project working

You need to add the following 5 lines to your service you want load balanced to docker-compose.yml

ports:
  - 3000 #ensure this is the correct port your service exposes
labels:
  - "SERVICE_3000_NAME=awesome-service" #adjust the port number here too, if needed
  - "SERVICE_3000_TAGS=load-balance"

Note: the ports line should NOT look like 3000:3000. It should be a single port number only. This allows docker to assign a RANDOM port to bind to on the host. Consul / Registrator / NGINX will handle this random port without issue. This prevents you from experiencing port conflicts!

Now run docker-compose up on your project.

Then simply go to http://awesome-service.tugboat.zone/ in your browser (because we set the name to be awesome-service)

SSL Support

This project DOES provide SSL support (but needs to be enabled, see below). By default, it uses a self-signed certificate. You will receive a warning when you try to load https://container.tugboat.zone, you can simply bypass the warning and continue.

The self-signed certificate likely will not work well for internal app-to-app communication since it will likely reject the cert. We personally just use http for that (it's internal anyways!), but you also have the option to use your own SSL certificate.

Custom Configuration

To use a custom configuration (enable SSL, custom SSL cert, custom domain) please run:

cp docker-compose.override.example.yml docker-compose.override.yml and then edit to your needs.

Note: If you use a custom domain, you need to also setup wildcard DNS to the IP 192.168.99.100. So if you use the domain tugboat.ninja, you need to setup *.tugboat.ninja to point to 192.168.99.100.

We own and have wildcard DNS set up for the following domains:

  • tugboat.zone
  • tugboat.ninja
  • tugboat.tools

Static Custom Configuration

Are you a company where you want all of your devs to use the same custom configuration? Well we are too, so we have you sorted there as well!

Head on over to Tugboat Bootstrapper to learn how to create a repo with static configs

What if I'm running linux?

Well, we don't officially support linux as our setup makes an assumption you are using the Docker Toolbox. However you can still get it working. You either need to create a virtual network interface bound on 192.168.99.100 or edit this project to change it to use your host IP and the using a custom domain which wildcards to your custom IP. This is out of the scope of this tool, but its still possible.

A virtual network interface is your best option.

If you know of a good way to adapt this tool to work with linux, feel free to submit a pull request.

Troubleshooting

None of the tugboat domains are resolving

There are two causes of this:

  1. You are using a router that has "rebind production" turned on, you will need to turn that off, or add an exception for this domain. DD-WRT and Open-WRT often enable it by default.
  2. Your DNS server doesn't allow hostnames to resolve to local IPs (eg: 192.168.x.x). You can try using Google's DNS servers (8.8.8.8 and 8.8.4.4).

Tugboat says my IP doesn't match 192.168.99.100

Tugboat relies on the fact that your VM is running on the default IP. Some situations can arise that cause it to use a different IP. There are two ways to fix this:

  1. Reboot your machine (not the VM).
  2. Run docker-machine stop default, ensure all virtualbox VMs are stopped, all virtualbox processes are stopped (including the GUI), and then run run docker-machine start default. If this doesn't work, see (1).

Notes on Docker Beta for Mac/Windows

Docker beta uses the IP 127.0.0.1 instead of 192.168.99.100. So you will need to use the hostnames beta.tugboat.tld which maps to 127.0.0.1.

See section Custom Configuration above.

Contributing

  1. Fork it ( https://github.com/articulate/tugboat/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • tecnobrat Brian Stolz - creator, maintainer

tugboat's People

Contributors

jewlofthelotus avatar pklingem avatar tecnobrat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.