0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00
Commit graph

25 commits

Author SHA1 Message Date
William Bezuidenhout
e2234497b7 proxy: Add, remove, or replace upstream and downstream headers (closes #666) (PR #788)
* Overwrite proxy headers based on directive

Headers of the request sent by the proxy upstream can now be modified in
the following way:

Prefix header with `+`: Header will be added if it doesn't exist
otherwise, the values will be merge
Prefix header with `-': Header will be removed
No prefix: Header will be replaced with given value

* Add missing formating directive reported by go vet

* Overwrite up/down stream proxy headers

Add Up/DownStreamHeaders to UpstreamHost

Split `proxy_header` option in `proxy` directive into `header_upstream`
and `header_downstream`. By splitting into two, it makes it clear in
what direction the given headers must be applied.

`proxy_header` can still be used (to maintain backward compatability)
but its assumed to be `header_upstream`

Response headers received by the reverse proxy from the upstream host
are updated according the `header_downstream` rules.
The update occurs through a func given to the reverse proxy, which is
applied once a response is received.

Headers (for upstream and downstream) can now be modified in
the following way:

Prefix header with `+`: Header will be added if it doesn't exist
otherwise, the values will be merge
Prefix header with `-': Header will be removed
No prefix: Header will be replaced with given value

Updated branch with changes from master

* minor refactor to make intent clearer

* Make Up/Down stream headers naming consistent

* Fix error descriptions to be more clear

* Fix lint issue
2016-04-30 13:41:30 -06:00
Matt Holt
81e26970a3 proxy: Move handling of headers around to prevent memory usage spikes (#784)
* Move handling of headers around to prevent memory use spikes

While debugging #782, I noticed that using http2 and max_fails=0,
X-Forwarded-For grew infinitely when an upstream request failed after
refreshing the test page. This change ensures that headers are only
set once per request rather than appending in a time-terminated loop.

* Refactor some code into its own function
2016-04-27 12:50:18 -06:00
Matthew Holt
f23d8cb37f Add {upstream} placeholder when proxy middleware is used (closes #531)
Middlewares can now make their own placeholders that may be useful in
logging, on a per-request basis. Proxy is the first one to do this.
2016-03-20 21:56:13 -06:00
Abiola Ibrahim
e7001e6538 Add except to FastCGI. Minor refactor in proxy. 2016-03-20 08:02:17 +01:00
Pieter Raubenheimer
a7766c9033 Add common method for checking host availability 2016-03-10 14:42:19 +00:00
eiszfuchs
7091a2090b created http.Transport and tests for unix sockets 2016-02-10 19:45:31 +01:00
Matthew Holt
82b049229b proxy: Add basic proxying test and InsecureSkipVerify transport test 2016-01-23 10:14:13 -07:00
Abiola Ibrahim
7949388da8 Proxy: Allow ignored subpaths. 2015-11-16 17:22:06 +01:00
Matthew Holt
6cbd3ab096 proxy: 64-bit word alignment for 32-bit systems (fixes #252) 2015-09-22 16:47:39 -06:00
Matthew Holt
04571ff393 NewReplacer takes third argument for empty value string 2015-07-24 10:27:19 -06:00
Zac Bergquist
41e1f1ffa5 Update error strings (start with lowercase letters) 2015-06-07 20:49:17 -04:00
Viacheslav Biriukov
593557659c fix tests and change naming 2015-06-04 13:57:39 +00:00
Viacheslav Biriukov
4790dacbf7 add without to proxy middleware 2015-06-03 18:06:24 +00:00
Zac Bergquist
506f131428 Fix lint warnings for middleware/proxy 2015-05-24 20:58:17 -04:00
Nimi Wariboko Jr
0ed5b364c6 Refactor proxy middleware so that 1.) From() is exposed 2.) Other upstreams can be implemented/plugged in 2015-05-04 19:58:18 -07:00
Matthew Holt
6029973bdc Major refactoring of middleware and parser in progress 2015-05-04 11:04:37 -06:00
Nimi Wariboko Jr
264e5b7911 Use the provided Replacer tools in order to proxy string interpolation. 2015-05-03 13:33:08 -07:00
Nimi Wariboko Jr
4a4b80450a Upgrade proxy middleware. Add support for: multiple backends, load balancing, health checks, and pluggable backends 2015-05-02 22:45:01 -07:00
Matthew Holt
d8e7adcdb4 Refactored proxy middleware 2015-04-11 17:24:47 -06:00
Matthew Holt
d33256f1dc Refactor: Middleware chain uses Handler instead of HandlerFunc 2015-04-02 23:30:54 -06:00
Matthew Holt
9f793dad28 Proxy destination may include scheme 2015-03-31 23:53:39 -06:00
Matthew Holt
6bf36d922c Refactored proxy middleware to return errors 2015-03-28 16:56:56 -06:00
Matthew Holt
0e43271cc9 Basic proxy feature works 2015-02-02 23:41:35 -07:00
Matthew Holt
ae2a2d5b00 Godoc for middleware packages and server package 2015-01-29 23:52:18 -07:00
Matthew Holt
13cf980879 Moved proxy middleware into its own package 2015-01-29 22:05:36 -07:00
Renamed from middleware/proxy.go (Browse further)