• Stars
    star
    106
  • Rank 325,871 (Top 7 %)
  • Language
    Go
  • Created over 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Complete proxy with much simpler configuration

Docker Nginx Auto Proxy

This docker image automatic proxies requests to your docker containers

Usage

Configuration

First, pull the image from docker hub

# use correct tag
docker pull stephenafamo/docker-nginx-auto-proxy:4.x.x 

Run a container

docker run --name nginx -v /path/to/my/config/directory:/docker/config -p 80:80 -p 443:443 stephenafamo/docker-nginx-auto-proxy:4.x.x

The container reads any file with the extension .toml in /docker/config. You can change this folder using the CONFIG_DIR environmental variable.

To easily manage all proxies, you should mount your own configuration directory. -v /path/to/my/config/dir:/docker/config

Variables

These are the environmental variables you can use to tweak the behaviour of this image.

  1. EMAIL: The email used to accept the TOS for getting Let's Encrypt certificates. REQUIRED
  2. CONFIG_DIR: This is a set of directories where the container will look for .config files. Multiple directories are separated with a colon :. Default /docker/config.
  3. CONFIG_RELOAD_TIME: This image automatically checks for changes to your configuration files. This environmental variable is used to set how long it should wait between checks. Default is 5s. Valid time units are "ns", "us" (or "ยตs"), "ms", "s", "m", "h". Examples of durations are:
    • 5s: 5 seconds
    • 1m: 1 minute
    • 1m30s: 1 minute, 30 seconds
    • 12h: 12 hours
  4. HTTPS_VALIDITY: How often the entire config should be purged and reconfigured even if there are no changes. This is useful for things like auto-renewing letsencrypt certificates. Default 168h(1 week).
  5. LETSENCRYPT_CREDS_DIR: The directory where credential files for certbot dns plugins will be placed. Default is /docker/letsencrypt-credentials
  6. LETSENCRYPT_DNS_PROPAGATION: Seconds to wait for dns propagation when using the dns authentication method. Default is 120

Writing configuration files

A configuration file is a set of defined services. You can put multiple services in a single file, and you can have multiple files in the CONFIG_DIR or any of its subdirectories. All configuration files must end with .toml. Services are defined using the toml format.

The parameters used to define a service are based on the type of proxy needed. HTTP or TCP/UDP.

Each service should be the TOML equivalient of the ServiceConfig type.

  • The top level Location, LocationOptions, Upstream, and UpstreamOptions are an easy way to set only a single key in Locations (where Match == Location). Since many services will define only a single location, it's easier to do
[unique-key]
domains = ["my.domain.com"]
upstream = [{address = "upstream.io"}]
ssl = true
sslSource = "letsencrypt"
httpsOnly = true

than:

[unique-key]
domains = ["my.domain.com"]
ssl = true
sslSource = "letsencrypt"
httpsOnly = true
[[unique-key.locations]]
upstream = [{address = "upstream.io"}]
match = "/"

Both ways are completely valid though.

See comments on the ServiceConfig. struct for details. Some examples will be added soon (PRs welcome).

Let's Encrypt

If set up correctly, the container will attempt to get a new certificate if there was none, or renew the certificate.

Certificates that were last configured {HTTPS_VALIDITY} ago will automatically be retried.

Roadmap

  • Load balancing with multiple containers DONE
  • Automatic SSL support with let's encrypt DONE
  • Allow custom ssl certificate configuration DONE

Please inform me of any issues or feature requests, Pull requests are appreciated.

More Repositories

1

bob

SQL query builder and ORM/Factory generator for Go with support for PostgreSQL, MySQL and SQLite
Go
717
star
2

orchestra

Orchestra is a library to manage long running go processes.
Go
152
star
3

goldmark-pdf

A PDF renderer for the goldmark markdown parser.
Go
117
star
4

scan

Scan provides the ability to to scan sql rows directly to any defined structure.
Go
69
star
5

laravel-2fa-starter

A laravel application with 2fa added to the registration and login flows
PHP
57
star
6

kronika

Kronika adds some extra utility around the standard time package. It does not have any other external dependencies.
Go
36
star
7

adonisjs-docker

A docker image for adonis.js applications
Shell
33
star
8

javascript-autocomplete-demo

JavaScript
27
star
9

isbot

Detect bots/crawlers/spiders using the user agent string.
Go
18
star
10

golangci-server

Go
15
star
11

audio-slideshow

Make audio based slideshows
JavaScript
13
star
12

go-site-boilerplate

a boilerplate for building webapps with golang
Go
13
star
13

woocommerce-global-cart

Global cart for woocommerce on WordPress multisite installs
PHP
13
star
14

boilingfactory

BoilingFactory is a CLI tool that generates factories for models generated by sqlboiler. https://github.com/volatiletech/sqlboiler.
Smarty
12
star
15

ci-bot

Go
12
star
16

boilingseed

BoilingSeed is a CLI tool that helps generate database seeding helpers with sqlboiler. https://github.com/volatiletech/sqlboiler.
Smarty
9
star
17

fakedb

fakedb registers a fake database driver named test for... testing.
Go
7
star
18

eventbus

Go
6
star
19

janus

A modular framework for Go web applications
Go
6
star
20

demo-site-hng-challenge

Source code for a nice UI concept
HTML
5
star
21

knowledgebase

knowldegebase is a tool to quickly start a knowledge base server or add one to a go web app.
Go
5
star
22

go-sql-builder-benchmarks

Benchmarking Golang SQL query builders
Go
5
star
23

sqlparser

Go Package to parse SQL statements for MySQL and SQLite
ANTLR
4
star
24

crdbstore

Gorilla's Session store implementation with cockroachDB
Go
3
star
25

typesql

SQL Query Builder for Go
Go
3
star
26

expense-tracker

Go
2
star
27

manticore-docker

A docker image for manticore search
2
star
28

audio-slideshow-wp-plugin

PHP
1
star
29

spa-nginx

Dockerfile
1
star
30

web-components

TypeScript
1
star
31

authboss-oauth1

Oauth1 module for Authboss (github.com/volatiletech/authboss)
Go
1
star
32

packr-migrate

A driver to read migration files for golang-migrate from packr boxes
Go
1
star
33

signup-login-ui-concept

Source code for a nice UI concept
JavaScript
1
star
34

jsctags-docker

docker image for jsctags. Tag js files without Node or NPM
Shell
1
star
35

at-ussd-airtime

PHP
1
star