Leonard Hecker
533039e6d8
proxy: Removed leftover restriction to HTTP/1.1
2016-12-29 16:07:22 +01:00
Leonard Hecker
b857265f9c
proxy: Fixed support for TLS verification of WebSocket connections
2016-12-28 17:38:54 +01:00
Leonard Hecker
153d4a5ac6
proxy: Improved handling of bufferPool
2016-12-28 17:17:52 +01:00
Mateusz Gajewski
d5fe4928f2
Remove pre 0.9 code ( #1304 )
...
* Remove pre 0.9 code
* Unused import
* gofmtw
2016-12-27 15:53:16 -07:00
Leonard Hecker
20483c23f8
Added end-to-end test case for #1292
2016-12-26 20:53:18 +01:00
Leonard Hecker
9f9ad21aaa
Fixed #1292 : Failure to proxy WebSockets over HTTPS
...
This issue was caused by connHijackerTransport trying to record HTTP
response headers by "hijacking" the Read() method of the plain net.Conn.
This does not simply work over TLS though since this will record the TLS
handshake and encrypted data instead of the actual content.
This commit fixes the problem by providing an alternative transport.DialTLS
which correctly hijacks the overlying tls.Conn instead.
2016-12-26 20:52:36 +01:00
Leonard Hecker
53635ba538
Fixed panic due to 0-length buffers being passed to io.CopyBuffer
2016-12-26 20:42:00 +01:00
Leonard Hecker
6352c9054a
Fixed proxy not respecting the -http2 flag
2016-12-26 20:40:44 +01:00
Leonard Hecker
a3aa414ff3
Fixed HTTP/2 support for the proxy middleware ( #1300 )
...
* Fixed HTTP/2 support for the proxy middleware
http.Transport instances whose TLSClientConfig, Dial, or DialTLS field
is non-nil will be configured without HTTP/2 support by default.
This commit adds the proper calls to http2.ConfigureTransport()
everywhere a http.Transport is created and thus fixes HTTP/2 in the
proxy middleware whenever insecure_skip_verify or keepalive is provided.
* Added HTTP/2 support check to TestReverseProxyInsecureSkipVerify
2016-12-21 12:44:07 -07:00
Guiheux Steven
8653b70c32
test: add unit test for #1283 ( #1288 )
2016-12-07 18:59:02 -07:00
Matthew Holt
36f8759a7b
Ensure some tests remove temporary directories they created
2016-11-28 22:26:54 -07:00
Gyula Voros
b783caaaed
Filter empty headers ( #1239 )
...
* Filter empty headers
Some web servers (e.g. Jetty 9.3) don’t like HTTP headers with empty values. This commit filters header replacements with zero length.
* Extend tests to verify removal of empty headers
* Handle add-header case
* Change - Use short variable assignment
2016-11-16 21:41:53 -07:00
Benny Ng
dd4c4d7eb6
proxy: record request Body for retry ( fixes #1229 )
2016-11-04 19:15:36 +08:00
Ngo The Trung
0cdaaba4b8
Add maxrequestbody directive ( #1163 )
2016-11-04 08:25:49 +08:00
Tw
e85ba0d4db
proxy: make value is optional when removing a header
...
fix issue #1234
Signed-off-by: Tw <tw19881113@gmail.com>
2016-11-03 22:50:51 +00:00
Mateusz Gajewski
8cc3416bbc
Remove dead code, do struct alignment, simplify code
2016-10-25 19:19:54 +02:00
Matt Holt
f3108bb7bf
Merge pull request #1207 from tw4452852/1206
...
proxy: set request's body to nil explicitly
2016-10-25 09:30:10 -06:00
Mateusz Gajewski
c2853ea64b
Use proper Request ( #1197 )
...
* Use proper Request
* Fixes
2016-10-25 09:28:53 -06:00
Tw
a1dd6f0b34
proxy: set request's body to nil explicitly
...
fix issue #1206
Signed-off-by: Tw <tw19881113@gmail.com>
2016-10-24 11:10:12 +08:00
Matt Holt
550b1170bd
Merge branch 'master' into 1173
2016-10-13 22:56:19 -06:00
Tw
4baca884c5
proxy: preserve path trailing slash if it was there
...
fix issue #1177
Signed-off-by: Tw <tw19881113@gmail.com>
2016-10-11 17:06:59 +08:00
Tw
d0455c7b9c
add more descriptive errors
...
Signed-off-by: Tw <tw19881113@gmail.com>
2016-10-11 10:34:51 +08:00
Tw
e5d33e73f3
header: implement http.Hijacker for responseWriterWrapper
...
fix issue #1173
Signed-off-by: Tw <tw19881113@gmail.com>
2016-10-11 08:53:47 +08:00
Tw
cc638c7faa
proxy: handle 'without' option in encoded form of URL path
...
fix issue #1154
Signed-off-by: Tw <tw19881113@gmail.com>
2016-10-02 19:32:14 +00:00
Matt Holt
8944332e13
Merge pull request #1143 from mholt/1136-fix
...
Fix #1136 - IP hash policy no longer changes host pool
2016-09-28 08:07:58 -06:00
Kris Hamoud
be1c57acfe
1136 fix
...
logic change
2016-09-28 04:09:46 -07:00
Matt Holt
871d11af00
Merge pull request #1135 from mholt/proxyerrs
...
proxy: Improve failover logic and retries
2016-09-27 17:53:44 -06:00
Matthew Holt
6397a85e50
proxy: Only wait 250ms between backend tries
2016-09-27 17:49:00 -06:00
Matthew Holt
617012c3fb
Use time.Since() for readability
2016-09-24 21:27:57 -06:00
Matt Holt
d01bcd591c
Merge pull request #1112 from tw4452852/proxy_header
...
proxy: don't append predefined headers
2016-09-24 21:02:19 -06:00
Tw
c9b022b5e0
proxy: don't append some predefined headers
...
fix issue #1086
Signed-off-by: Tw <tw19881113@gmail.com>
2016-09-25 09:24:27 +00:00
Matthew Holt
a661007a55
proxy: Fix retry logic for when no hosts are available
2016-09-24 16:30:40 -06:00
Matthew Holt
0c0142c8cc
Delete tryDuration, now unused
2016-09-24 16:05:33 -06:00
Matthew Holt
37f05e450f
proxy: Add try_duration and try_interval; by default don't retry
2016-09-24 16:03:22 -06:00
Matthew Holt
9b9a77a160
proxy: Improved error reporting
...
We now report the actual error message rather than a generic one
2016-09-24 14:22:13 -06:00
Tw
4670d13c8c
proxy: fix checking error in TestDownstreamHeadersUpdate and TestUpstreamHeadersUpdate
...
Signed-off-by: Tw <tw19881113@gmail.com>
2016-09-24 19:28:42 +00:00
Matthew Holt
76d9d695be
Remove use of proxy_header in test
2016-09-24 12:27:16 -06:00
Issac Trotts
1991083322
Fix tests to not make long unix domain socketpaths
...
Some tests were running into this issue:
https://github.com/golang/go/issues/6895
Putting the sockets into temp dirs fixes the problem.
2016-08-29 18:09:46 -07:00
Michael Grosser
3dc98c8ce3
Keep quic protocol headers only between one hop
...
Removing quic protocol headers from being persisted during proxy requests.
Not removing them could lead to the client attempting to connect to the wrong port.
This makes the quic headers consistent with other protocol headers.
2016-08-23 22:05:56 +00:00
Nimi Wariboko Jr
2ef8905966
Proxy: Instead of setting DisableKeepAlives, set MaxIdleConnsPerHost to -1 to prevent net/http from pooling the connections. DisableKeepAlives causes net/http to send a Connection: Closed header which is bad. Fixes #1056
2016-08-22 18:00:37 -07:00
Matthew Holt
ce8b1dfe94
Warn upon use of proxy_header
2016-08-08 13:48:13 -06:00
Matthew Holt
2019eec5a5
Fix lint warnings; group methods for same type together
2016-08-06 14:46:52 -06:00
Nimi Wariboko Jr
8898066455
Merge branch 'master' into proxy/single-webconn
2016-08-05 16:57:54 -07:00
Nimi Wariboko Jr
824ec6cb95
Merge branch 'master' into proxy/keepalive-directive
2016-08-05 16:20:37 -07:00
Nimi Wariboko Jr
5b5e365295
Instead of treating 0 is a default value, use http.DefaultMaxIdleConnsPerHost
2016-08-05 15:41:32 -07:00
Tw
94c63e42d6
proxy: add Host header checking
...
fix issue #993
Signed-off-by: Tw <tw19881113@gmail.com>
2016-08-04 13:07:20 +08:00
Nimi Wariboko Jr
6e9439d22e
Proxy: Fix data race in test.
2016-08-02 12:39:15 -07:00
Nimi Wariboko Jr
f4cdf53761
Proxy: Fix transport defn; cleanup connection.
2016-08-02 12:31:17 -07:00
Nimi Wariboko Jr
d534a2139f
Proxy: When connecting to websocket backend, reuse the connection isntead of starting a new one.
2016-08-01 19:11:31 -07:00
Eric Drechsel
c4e65df262
Proxy: Add a failing test which replicates #763
...
2 websocket connections are made instead of one
2016-08-01 19:09:02 -07:00
Kris Hamoud
88d3dcae42
added ip_hash load balancing
...
updated tests
fixed comment format
fixed formatting, minor logic fix
added newline to EOF
updated logic, fixed tests
added comment
updated formatting
updated test output
fixed typo
2016-08-01 18:50:53 -07:00
Nimi Wariboko Jr
db4cd8ee2d
Proxy: Add keepalive directive to proxy to set MaxIdleConnsPerHost on transport. Fixes #938
2016-08-01 15:54:07 -07:00
Matthew Holt
c8daaba4be
Update link to SA 1.1.1 (and other minor tweaks)
2016-07-28 11:11:14 -06:00
Viacheslav Chimishuk
62e8c4b76b
Use authentification credentials from proxy's configuration as a default. ( #951 )
2016-07-22 11:33:50 -06:00
Matthew Holt
6490ff6224
Adjust proxy headers properly ( fixes #916 )
2016-07-21 18:18:01 -06:00
Matthew Holt
57710e8b0d
Revert "Merge pull request #931 from pedronasser/master"
...
This reverts commit 9ea0591951
, reversing
changes made to 2125ae5f99
.
2016-07-21 13:31:43 -06:00
Tw
ca3d23bc70
proxy: fix hyphen issue when parsing target
...
fix issue #948
Signed-off-by: Tw <tw19881113@gmail.com>
2016-07-21 13:56:35 +08:00
Tw
beae16f07c
Proxy performance ( #946 )
...
* proxy: add benchmark
Signed-off-by: Tw <tw19881113@gmail.com>
* replacer: prepare lazily
update issue#939
benchmark old ns/op new ns/op delta
BenchmarkProxy-4 83865 72544 -13.50%
Signed-off-by: Tw <tw19881113@gmail.com>
* proxy: use buffer pool to avoid temporary allocation
Signed-off-by: Tw <tw19881113@gmail.com>
2016-07-20 19:06:14 -06:00
Matthew Holt
aede4ccbce
Small changes; mostly comments
2016-07-18 14:32:28 -06:00
Pedro Nasser
6bb1e0c674
improve transparent mode
2016-07-14 18:16:58 -03:00
Pedro Nasser
b58872925a
fixed transparent host and added test case
2016-07-14 15:43:06 -03:00
Pedro Nasser
8d7136fc06
fix transparent host header #916
2016-07-14 15:30:00 -03:00
Matthew Holt
62622eb853
proxy: 'transparent' also sets X-Forwarded-For ( closes #924 )
2016-07-09 17:33:40 -06:00
Maxime
e5bf8cab24
Test that the host header forwarding on the proxy middleware
2016-06-29 16:52:31 -07:00
Matthew Holt
a1bc94e409
Working on a fix for proxy related to setting Host header (cf. #874 )
...
Also see
https://forum.caddyserver.com/t/caddy-0-9-beta-version-available-updated-beta-2/146/29?u=matt
which has another account of strange proxy behavior; I think this
resolves that.
2016-06-28 18:40:07 -06:00
Matthew Holt
80dd95a495
Change outreq.Host instead of r.Host (possibly related to #874 )
...
Also a few little formatting changes and comments.
2016-06-28 18:19:35 -06:00
Viacheslav Biriukov
345ece3850
add multi proxy supprot based on urls
2016-06-28 16:35:35 -06:00
Matthew Holt
a798e0c951
Refactor how caddy.Context is stored and used
...
- Server types no longer need to store their own contexts; they are
stored on the caddy.Instance, which means each context will be
properly GC'ed when the instance is stopped. Server types should use
type assertions to convert from caddy.Context to their concrete
context type when they need to use it.
- Pass the entire context into httpserver.GetConfig instead of only the
Key field.
- caddy.NewTestController now requires a server type string so it can
create a controller with the proper concrete context associated with
that server type.
Tests still need more attention so that we can test the proper creation
of startup functions, etc.
2016-06-20 11:59:23 -06:00
David Dyke
07b7c99965
Add timeout to health_check ( #887 )
...
* Add timeout to http get on health_check
* Add new test and up the timeout
* Tests for change to default timeout
* Only call http client once and make options more inline with current caddy directives
2016-06-20 09:49:21 -06:00
Andrew Hamon
a50462974c
Refactor and clean up policy code
...
This commit shouldn't change any behavior. It is simply a cleanup of
the different proxy policies. It also adds some comments explaining the
sampling method used, since on first inspection it might not appear to
be a uniformly random selection.
2016-06-18 15:41:18 -05:00
Andrew Hamon
fee4890e94
Balance round robin evenly when some hosts are down ( #880 )
...
* Balance round robin evenly when some hosts are down
Before, when load balancing across multiple hosts, if a host went down
then the next host in line would be sent a double share of requests.
This is because the round robin counter was only incremented once per
request, regardless of the health of the selection. If current
selection was unhealthy then the policy would advance to the next host,
but this would not be reflected in the policy counter. To fix this, the
counter is now incremented for every attempted host.
This commit adds a test case that identifies the issue, and a fix.
* Make robin counter private
* Use a mutex to sync round robin selection
2016-06-14 15:43:06 -06:00
David Dyke
b14baf7e20
Add proxy preset: transparent ( #881 )
...
* Add reverse_proxy preset
* Update to 'transparent' preset instead of 'reverse_proxy'
2016-06-14 12:03:30 -06:00
Matthew Holt
d3860f95f5
Make RegisterPlugin() more consistent, having name as first argument
2016-06-06 15:31:03 -06:00
Matthew Holt
416af05a00
Migrating more middleware packages
2016-06-05 21:51:56 -06:00