Commit Graph

18 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
3faad41b43
middleware: ResponseRecorder now is an http.Flusher (fixes #677)
Flush every 250ms. This should keep latency somewhat low but there is
still buffering; maybe in the future we can make this configurable.
2016-04-09 00:17:15 -06:00
Ruben Callewaert
1a9f700287 Allow mixed case Upgrade headers
Caddy expects websocket to be completely lowercase.
Some applications send websocket upgrade headers like the following:
`Upgrade: WebSocket`

This change allows all variations of websocket.
2016-04-03 17:48:53 +02:00
eiszfuchs
cbd9b814b9 fixed req.URL.Path for unix: sockets 2016-03-28 22:18:14 +02:00
eiszfuchs
7091a2090b created http.Transport and tests for unix sockets 2016-02-10 19:45:31 +01:00
Matthew Holt
9e900b0a08 godoc 2016-01-25 20:45:23 -07:00
Filippo Valsorda
bae4ac9764 proxy: add a insecure_skip_verify option - closes #320 2016-01-23 03:26:31 +00:00
Luit van Drongelen
1fb66d534a Close proxy's backend request earlier when re-connecting for websocket 2015-11-21 20:03:46 +01:00
Luit van Drongelen
f0b1edaf8c Fix proxy for websocket with altered Host header 2015-11-21 20:00:44 +01: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
Matthew Holt
9ce0e8e17c proxy: Added tests for reverse websocket proxy 2015-06-01 22:39:53 -06:00
Austin
68cd4bdeab check server response instead of client 2015-06-01 19:29:32 -07:00
Austin
ccd3e55b32 changes as noted in PR 2015-06-01 10:23:57 -07:00
Austin
56ec7b9887 websocket directive, upgrade comparison 2015-05-30 11:34:54 -07:00
Austin
2d6ff40649 add supported for ws in reverse proxy 2015-05-29 19:21:50 -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