@marcel91200 / caddy Mirror · read-only / commits / 6f73a358
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

httpcaddyfile: Add `compression` to http transport config (#3624)

* httpcaddyfile: Add `compression` to http transport config * Add caddyfile adapt test for typical h2c setup

Ye Zhihao committed Aug 1, 2020 at 01:30 UTC 6f73a358f43013a43c55d57f0c7726a6277f62b6
2 files changed +104
caddytest/integration/caddyfile_adapt/reverse_proxy_h2c.txt new
+96
@@ -0,0 +1,96 @@
1 +
2 +https://example.com {
3 + reverse_proxy /path http://localhost:54321 {
4 + header_up Host {host}
5 + header_up X-Real-IP {remote}
6 + header_up X-Forwarded-For {remote}
7 + header_up X-Forwarded-Port {server_port}
8 + header_up X-Forwarded-Proto "http"
9 + transport http {
10 + versions h2c 2
11 + compression off
12 + }
13 + }
14 +}
15 +
16 +----------
17 +{
18 + "apps": {
19 + "http": {
20 + "servers": {
21 + "srv0": {
22 + "listen": [
23 + ":443"
24 + ],
25 + "routes": [
26 + {
27 + "match": [
28 + {
29 + "host": [
30 + "example.com"
31 + ]
32 + }
33 + ],
34 + "handle": [
35 + {
36 + "handler": "subroute",
37 + "routes": [
38 + {
39 + "handle": [
40 + {
41 + "handler": "reverse_proxy",
42 + "headers": {
43 + "request": {
44 + "set": {
45 + "Host": [
46 + "{http.request.host}"
47 + ],
48 + "X-Forwarded-For": [
49 + "{http.request.remote}"
50 + ],
51 + "X-Forwarded-Port": [
52 + "{server_port}"
53 + ],
54 + "X-Forwarded-Proto": [
55 + "http"
56 + ],
57 + "X-Real-Ip": [
58 + "{http.request.remote}"
59 + ]
60 + }
61 + }
62 + },
63 + "transport": {
64 + "compression": false,
65 + "protocol": "http",
66 + "versions": [
67 + "h2c",
68 + "2"
69 + ]
70 + },
71 + "upstreams": [
72 + {
73 + "dial": "localhost:54321"
74 + }
75 + ]
76 + }
77 + ],
78 + "match": [
79 + {
80 + "path": [
81 + "/path"
82 + ]
83 + }
84 + ]
85 + }
86 + ]
87 + }
88 + ],
89 + "terminal": true
90 + }
91 + ]
92 + }
93 + }
94 + }
95 + }
96 +}
modules/caddyhttp/reverseproxy/caddyfile.go
+8
@@ -719,6 +719,14 @@ func (h *HTTPTransport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
719 return d.ArgErr()
720 }
721
722 + case "compression":
723 + if d.NextArg() {
724 + if d.Val() == "off" {
725 + var disable bool
726 + h.Compression = &disable
727 + }
728 + }
729 +
730 default:
731 return d.Errf("unrecognized subdirective %s", d.Val())
732 }