Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kmfischer3 committed Aug 3, 2018
2 parents 49d37c0 + 79d46e3 commit 2b462e8
Show file tree
Hide file tree
Showing 37 changed files with 1,519 additions and 150 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fabio
dist/
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
*-amd64
*.out
*.orig
*.out
*.p12
*.pem
*.pprof
*.sha256
*.swp
*.tar.gz
*.test
*.un~
*.zip
.DS_Store
.idea
.vagrant
Expand Down
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

### Unreleased

#### Breaking Changes

#### Bug Fixes

* [Issue #506](https://github.com/fabiolb/fabio/issues/506): Wrong route for multiple matching host glob patterns

When multiple host glob patterns match an incoming request fabio can pick the wrong backend for the request.
This is because the sorting code that should sort the matching patterns from most specific to least specific
does not take into account that doamin names have their most specific part at the front. This has been fixed
by reversing the domain names before sorting.

#### Improvements

#### Features

### [v1.5.9](https://github.com/fabiolb/fabio/releases/tag/v1.5.9) - 16 May 2018

#### Notes

* [Issue #494](https://github.com/fabiolb/fabio/issues/494): Tests fail with Vault > 0.9.6 and Consul > 1.0.6

Needs more investigation.

#### Breaking Changes

* None
Expand All @@ -21,6 +44,17 @@

Thanks to [@tino](https://github.com/tino) for the patch.

* [Issue #421](https://github.com/fabiolb/fabio/issues/421): Fabio routing to wrong backend

Fabio does not close websocket connections if the connection upgrade fails. This can lead to
connections being routed to the wrong backend if there is another HTTP router like nginx in
front of fabio. The failed websocket connection creates a direct TCP tunnel to the original
backend server and that connection is not closed properly.

The patches detect an unsuccessful handshake and close the connection properly.

Thanks to [@craigday](https://github.com/craigday) for the original reporting and debugging.

#### Improvements

* [Issue #427](https://github.com/fabiolb/fabio/issues/427): Fabio does not remove service when one of the registered health-checks fail
Expand Down
15 changes: 15 additions & 0 deletions Dockerfile-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ubuntu
RUN apt-get update && apt-get -y install unzip make git-core
ARG consul_version
ARG vault_version
ARG go_version
COPY consul_${consul_version}_linux_amd64.zip /tmp
COPY vault_${vault_version}_linux_amd64.zip /tmp
COPY go${go_version}.linux-amd64.tar.gz /tmp
RUN unzip /tmp/consul_${consul_version}_linux_amd64.zip -d /usr/local/bin
RUN unzip /tmp/vault_${vault_version}_linux_amd64.zip -d /usr/local/bin
RUN tar -C /usr/local -x -f /tmp/go${go_version}.linux-amd64.tar.gz
ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH
WORKDIR /root/go/src/github.com/fabiolb/fabio
COPY . .
CMD "/bin/bash"
51 changes: 37 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ LAST_TAG = $(shell git describe --abbrev=0)
# e.g. 1.5.5
VERSION = $(shell git describe --abbrev=0 | cut -c 2-)

# GO runs the go binary with garbage collection disabled for faster builds.
# Do not specify a full path for go since travis will fail.
GO = go

# GOFLAGS is the flags for the go compiler. Currently, only the version number is
# passed to the linker via the -ldflags.
GOFLAGS = -ldflags "-X main.version=$(CUR_TAG)"
Expand All @@ -30,6 +26,11 @@ GOVENDOR = $(shell which govendor)
# VENDORFMT is the path to the vendorfmt binary.
VENDORFMT = $(shell which vendorfmt)

# pin versions for CI builds
CI_CONSUL_VERSION=1.0.6
CI_VAULT_VERSION=0.9.6
CI_GO_VERSION=1.10.2

# all is the default target
all: test

Expand All @@ -46,20 +47,20 @@ help:

# build compiles fabio and the test dependencies
build: checkdeps vendorfmt gofmt
$(GO) build
go build

# test runs the tests
test: build
$(GO) test -v -test.timeout 15s `go list ./... | grep -v '/vendor/'`
go test -v -test.timeout 15s `go list ./... | grep -v '/vendor/'`

# checkdeps ensures that all required dependencies are vendored in
checkdeps:
[ -x "$(GOVENDOR)" ] || $(GO) get -u github.com/kardianos/govendor
[ -x "$(GOVENDOR)" ] || go get -u github.com/kardianos/govendor
govendor list +e | grep '^ e ' && { echo "Found missing packages. Please run 'govendor add +e'"; exit 1; } || : echo

# vendorfmt ensures that the vendor/vendor.json file is formatted correctly
vendorfmt:
[ -x "$(VENDORFMT)" ] || $(GO) get -u github.com/magiconair/vendorfmt/cmd/vendorfmt
[ -x "$(VENDORFMT)" ] || go get -u github.com/magiconair/vendorfmt/cmd/vendorfmt
vendorfmt

# gofmt runs gofmt on the code
Expand All @@ -68,11 +69,11 @@ gofmt:

# linux builds a linux binary
linux:
GOOS=linux GOARCH=amd64 $(GO) build -tags netgo $(GOFLAGS)
GOOS=linux GOARCH=amd64 go build -tags netgo $(GOFLAGS)

# install runs go install
install:
$(GO) install $(GOFLAGS)
go install $(GOFLAGS)

# pkg builds a fabio.tar.gz package with only fabio in it
pkg: build test
Expand All @@ -86,7 +87,7 @@ pkg: build test
# later targets can pick up the new tag value.
release:
$(MAKE) tag
$(MAKE) preflight test gorelease homebrew docker-aliases
$(MAKE) preflight docker-test gorelease homebrew docker-aliases

# preflight runs some checks before a release
preflight:
Expand Down Expand Up @@ -115,12 +116,34 @@ docker-aliases:
docker push magiconair/fabio:$(VERSION)-$(GOVERSION)
docker push magiconair/fabio:latest

# docker-test runs make test in a Docker container with
# pinned versions of the external dependencies
#
# We download the binaries outside the Docker build to
# cache the binaries and prevent repeated downloads since
# ADD <url> downloads the file every time.
docker-test:
test -r consul_$(CI_CONSUL_VERSION)_linux_amd64.zip || \
wget https://releases.hashicorp.com/consul/$(CI_CONSUL_VERSION)/consul_$(CI_CONSUL_VERSION)_linux_amd64.zip
test -r vault_$(CI_VAULT_VERSION)_linux_amd64.zip || \
wget https://releases.hashicorp.com/vault/$(CI_VAULT_VERSION)/vault_$(CI_VAULT_VERSION)_linux_amd64.zip
test -r go$(CI_GO_VERSION).linux-amd64.tar.gz || \
wget https://dl.google.com/go/go$(CI_GO_VERSION).linux-amd64.tar.gz
docker build \
--build-arg consul_version=$(CI_CONSUL_VERSION) \
--build-arg vault_version=$(CI_VAULT_VERSION) \
--build-arg go_version=$(CI_GO_VERSION) \
-t test-fabio \
-f Dockerfile-test \
.
docker run -it test-fabio make test

# codeship runs the CI on codeship
codeship:
go version
go env
wget -O ~/consul.zip https://releases.hashicorp.com/consul/1.0.6/consul_1.0.6_linux_amd64.zip
wget -O ~/vault.zip https://releases.hashicorp.com/vault/0.9.3/vault_0.9.3_linux_amd64.zip
wget -O ~/consul.zip https://releases.hashicorp.com/consul/$(CI_CONSUL_VERSION)/consul_$(CI_CONSUL_VERSION)_linux_amd64.zip
wget -O ~/vault.zip https://releases.hashicorp.com/vault/$(CI_VAULT_VERSION)/vault_$(CI_VAULT_VERSION)_linux_amd64.zip
unzip -o -d ~/bin ~/consul.zip
unzip -o -d ~/bin ~/vault.zip
vault --version
Expand All @@ -129,7 +152,7 @@ codeship:

# clean removes intermediate files
clean:
$(GO) clean
go clean
rm -rf pkg dist fabio
find . -name '*.test' -delete

Expand Down
11 changes: 8 additions & 3 deletions NOTICES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ License: MPL-2 (https://github.com/hashicorp/vault/LICENSE)
Copyright 2017 HashiCorp, Inc.


github.com/magiconair/go-metrics-statsd
https://github.com/magiconair/go-metrics-statsd
License: MIT (https://github.com/magiconair/go-metrics-statsd/LICENSE)
github.com/pubnub/go-metrics-statsd
https://github.com/pubnub/go-metrics-statsd
License: MIT (https://github.com/pubnub/go-metrics-statsd/LICENSE)
Copyright (c) 2016 PubNub


Expand Down Expand Up @@ -157,3 +157,8 @@ golang.org/x/sync/singleflight
https://golang.org/x/sync/singleflight
License: BSD 3-clause (https://golang.org/x/sync/LICENSE)
Copyright (c) 2009 The Go Authors. All rights reserved.

github.com/mholt/caddy
https://github.com/mholt/caddy
License: Apache 2.0 (https://github.com/mholt/caddy/LICENSE.txt)
Copyright (c) 2015, Light Code Labs, LLC
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<a href="https://github.com/fabiolb/fabio/releases/latest"><img alt="Release" src="https://img.shields.io/github/release/fabiolb/fabio.svg?style=flat-square"></a>
<a href="https://raw.githubusercontent.com/fabiolb/fabio/master/LICENSE"><img alt="License MIT" src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square"></a>
<a href="https://app.codeship.com/projects/222209"><img alt="Codeship CI Status" src="https://img.shields.io/codeship/3e8307d0-2426-0135-1183-6e6f38f65fc4/master.svg?label=codeship&style=flat-square"></a>
<a href="https://travis-ci.org/fabiolb/fabio"><img alt="Travis CI Status" src="https://img.shields.io/travis/fabiolb/fabio.svg?label=travis-ci&style=flat-square"></a>
<a href="https://github.com/fabiolb/fabio/releases"><img alt="Downloads" src="https://img.shields.io/github/downloads/fabiolb/fabio/total.svg?style=flat-square"></a>
<a href="https://hub.docker.com/r/magiconair/fabio/"><img alt="Docker Pulls magiconair" src="https://img.shields.io/docker/pulls/magiconair/fabio.svg?style=flat-square&label=docker+pulls+magiconair"></a>
<a href="https://hub.docker.com/r/fabiolb/fabio/"><img alt="Docker Pulls fabiolb" src="https://img.shields.io/docker/pulls/fabiolb/fabio.svg?style=flat-square&label=docker+pulls+fabiolb"></a>
Expand Down Expand Up @@ -70,8 +69,8 @@ The full documentation is on [fabiolb.net](https://fabiolb.net/)
1. Install from source, [binary](https://github.com/fabiolb/fabio/releases),
[Docker](https://hub.docker.com/r/fabiolb/fabio/) or [Homebrew](http://brew.sh).
```shell
# go 1.8 or higher is required
go get github.com/fabiolb/fabio (>= go1.8)
# go 1.9 or higher is required
go get github.com/fabiolb/fabio (>= go1.9)

brew install fabio (OSX/macOS stable)
brew install --devel fabio (OSX/macOS devel)
Expand All @@ -87,8 +86,7 @@ The full documentation is on [fabiolb.net](https://fabiolb.net/)

3. Register a **health check** in consul as described [here](https://consul.io/docs/agent/checks.html).

Make sure the health check is **passing** since fabio will only watch services
which have a passing health check.
By default fabio only watches services which have a **passing** health check, unless overriden with [registry.consul.service.status](https://fabiolb.net/ref/registry.consul.service.status/).

4. Register one `urlprefix-` tag per `host/path` prefix it serves, e.g.:

Expand Down Expand Up @@ -125,7 +123,7 @@ urlprefix-:3306 proto=tcp # route external port 3306
### Contributors
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
<a href="graphs/contributors"><img src="https://opencollective.com/fabio/contributors.svg?width=890" /></a>
<a href="https://github.com/fabiolb/fabio/graphs/contributors"><img src="https://opencollective.com/fabio/contributors.svg?width=890" /></a>
### Backers
Expand Down
9 changes: 9 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Config struct {
UI UI
Runtime Runtime
Tracing Tracing
FastCGI FastCGI
ProfileMode string
ProfilePath string
Insecure bool
Expand Down Expand Up @@ -155,3 +156,11 @@ type Tracing struct {
SamplerRate float64
SpanHost string
}

type FastCGI struct {
Index string
Root string
SplitPath string
ReadTimeout time.Duration
WriteTimeout time.Duration
}
8 changes: 8 additions & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,12 @@ var defaultConfig = &Config{
SamplerRate: -1,
SpanHost: "localhost:9998",
},

FastCGI: FastCGI{
Root: "",
Index: "index.php",
SplitPath: ".php",
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
},
}
5 changes: 5 additions & 0 deletions config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ func load(cmdline, environ, envprefix []string, props *properties.Properties) (c
f.StringVar(&cfg.Tracing.Topic, "tracing.Topic", defaultConfig.Tracing.Topic, "OpenTrace Collector Kafka Topic")
f.Float64Var(&cfg.Tracing.SamplerRate, "tracing.SamplerRate", defaultConfig.Tracing.SamplerRate, "OpenTrace sample rate percentage in decimal form")
f.StringVar(&cfg.Tracing.SpanHost, "tracing.SpanHost", defaultConfig.Tracing.SpanHost, "Host:Port info to add to spans")
f.StringVar(&cfg.FastCGI.Index, "fcgi.index", defaultConfig.FastCGI.Index, "FastCGI index file name")
f.StringVar(&cfg.FastCGI.Root, "fcgi.root", defaultConfig.FastCGI.Root, "Document root of FastCGI upstream")
f.StringVar(&cfg.FastCGI.SplitPath, "fcgi.path.split", defaultConfig.FastCGI.SplitPath, "String literal to split the document path")
f.DurationVar(&cfg.FastCGI.ReadTimeout, "fcgi.timeout.read", defaultConfig.FastCGI.ReadTimeout, "FastCGI request read timeout")
f.DurationVar(&cfg.FastCGI.WriteTimeout, "fcgi.timeout.write", defaultConfig.FastCGI.WriteTimeout, "FastCGI request write timeout")

// deprecated flags
var proxyLogRoutes string
Expand Down
14 changes: 14 additions & 0 deletions docs/content/feature/fastcgi-upstream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: "FastCGI Upstream"
---

To support FastCGI upstream add `proto=fcgi` option to the `urlprefix-` tag.

FastCGI upstreams support following configuration options:

- `index`: Used to specify the index file that should be used if the request URL does not contain a
file.
- `root`: Document root of the FastCGI server.

Note that `index` and `root` can also be set in Fabio configuration as global default.

4 changes: 4 additions & 0 deletions docs/content/quickstart/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ and you need to add a separate `urlprefix-` tag for every `host/path` prefix the

# TCP examples
urlprefix-:3306 proto=tcp # route external port 3306

# Fast-CGI example
urlprefix-/blog proto=fcgi
urlprefix-/home proto=fcgi strip=/home
```

5. Start fabio without a config file
Expand Down
12 changes: 12 additions & 0 deletions docs/content/ref/fcgi.index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: "fcgi.index"
---

`fcgi.index` configures the index file to be used in FastCGI requests if the URL does not contain
it.

Default value is

```
fcgi.index = index.php
```
12 changes: 12 additions & 0 deletions docs/content/ref/fcgi.path.split.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: "fcgi.path.split"
---

`fcgi.path.split` specifies how to split the URL; the split value becomes the end of the first part
and anything in the URL after it becomes part of the `PATH_INFO` CGI variable.

Default value is

```
fcgi.path.split = .php
```
11 changes: 11 additions & 0 deletions docs/content/ref/fcgi.root.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "fcgi.root"
---

`fcgi.root` sets the document root for FastCGI requests.

Default value is empty string

```
fcgi.root =
```
Loading

0 comments on commit 2b462e8

Please sign in to comment.