Skip to content

Commit

Permalink
Merge branch 'fcgi-handler' of https://github.com/Gufran/fabio
Browse files Browse the repository at this point in the history
  • Loading branch information
magiconair committed Jun 10, 2018
2 parents 8489b4e + c87a304 commit 0daf269
Show file tree
Hide file tree
Showing 20 changed files with 1,266 additions and 28 deletions.
5 changes: 5 additions & 0 deletions NOTICES.txt
Original file line number Diff line number Diff line change
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
9 changes: 9 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Config struct {
Metrics Metrics
UI UI
Runtime Runtime
FastCGI FastCGI
ProfileMode string
ProfilePath string
Insecure bool
Expand Down Expand Up @@ -144,3 +145,11 @@ type Consul struct {
CheckDeregisterCriticalServiceAfter string
ChecksRequired string
}

type FastCGI struct {
Index string
Root string
SplitPath string
ReadTimeout time.Duration
WriteTimeout time.Duration
}
7 changes: 7 additions & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,11 @@ var defaultConfig = &Config{
Color: "light-green",
Access: "rw",
},
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 @@ -186,6 +186,11 @@ func load(cmdline, environ, envprefix []string, props *properties.Properties) (c
f.StringVar(&cfg.UI.Title, "ui.title", defaultConfig.UI.Title, "optional title for the UI")
f.StringVar(&cfg.ProfileMode, "profile.mode", defaultConfig.ProfileMode, "enable profiling mode, one of [cpu, mem, mutex, block]")
f.StringVar(&cfg.ProfilePath, "profile.path", defaultConfig.ProfilePath, "path to profile dump file")
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 =
```
11 changes: 11 additions & 0 deletions docs/content/ref/fcgi.timeout.read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "fcgi.timeout.read"
---

`fcgi.timeout.read` is the time allowed to read a response from upstream.

Default value is

```
fcgi.timeout.read = 10s
```
11 changes: 11 additions & 0 deletions docs/content/ref/fcgi.timeout.write.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "fcgi.timeout.write"
---

`fcgi.timeout.write` is the time allowed to upload complete request to upstream.

Default value is

```
fcgi.timeout.write = 10s
```
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func newHTTPProxy(cfg *config.Config) http.Handler {
}

return &proxy.HTTPProxy{
Config: cfg.Proxy,
Config: cfg,
Transport: newTransport(nil),
InsecureTransport: newTransport(&tls.Config{InsecureSkipVerify: true}),
Lookup: func(r *http.Request) *route.Target {
Expand Down
Loading

0 comments on commit 0daf269

Please sign in to comment.