@marcel91200 / caddy Mirror · read-only / commits / aa9c3eb7
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

reverseproxy: default to port 80 for upstreams in Caddyfile (#3772)

* reverseproxy: default to port 80 for port-less upstream dial addresses * reverseproxy: replace integration test with an adapter test Fixes #3761

Mohammed Al Sahaf committed Oct 1, 2020 at 22:53 UTC aa9c3eb7324461c0dd4f1dd28e767d0b8d0d7ec3
2 files changed +116
caddytest/integration/caddyfile_adapt/portless_upstream.txt new
+113
@@ -0,0 +1,113 @@
1 +whoami.example.com {
2 + reverse_proxy whoami
3 +}
4 +
5 +app.example.com {
6 + reverse_proxy app:80
7 +}
8 +unix.example.com {
9 + reverse_proxy unix//path/to/socket
10 +}
11 +----------
12 +{
13 + "apps": {
14 + "http": {
15 + "servers": {
16 + "srv0": {
17 + "listen": [
18 + ":443"
19 + ],
20 + "routes": [
21 + {
22 + "match": [
23 + {
24 + "host": [
25 + "whoami.example.com"
26 + ]
27 + }
28 + ],
29 + "handle": [
30 + {
31 + "handler": "subroute",
32 + "routes": [
33 + {
34 + "handle": [
35 + {
36 + "handler": "reverse_proxy",
37 + "upstreams": [
38 + {
39 + "dial": "whoami:80"
40 + }
41 + ]
42 + }
43 + ]
44 + }
45 + ]
46 + }
47 + ],
48 + "terminal": true
49 + },
50 + {
51 + "match": [
52 + {
53 + "host": [
54 + "unix.example.com"
55 + ]
56 + }
57 + ],
58 + "handle": [
59 + {
60 + "handler": "subroute",
61 + "routes": [
62 + {
63 + "handle": [
64 + {
65 + "handler": "reverse_proxy",
66 + "upstreams": [
67 + {
68 + "dial": "unix//path/to/socket"
69 + }
70 + ]
71 + }
72 + ]
73 + }
74 + ]
75 + }
76 + ],
77 + "terminal": true
78 + },
79 + {
80 + "match": [
81 + {
82 + "host": [
83 + "app.example.com"
84 + ]
85 + }
86 + ],
87 + "handle": [
88 + {
89 + "handler": "subroute",
90 + "routes": [
91 + {
92 + "handle": [
93 + {
94 + "handler": "reverse_proxy",
95 + "upstreams": [
96 + {
97 + "dial": "app:80"
98 + }
99 + ]
100 + }
101 + ]
102 + }
103 + ]
104 + }
105 + ],
106 + "terminal": true
107 + }
108 + ]
109 + }
110 + }
111 + }
112 + }
113 +}
modules/caddyhttp/reverseproxy/caddyfile.go
+3
@@ -155,6 +155,9 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
155 if err != nil {
156 host = upstreamAddr
157 }
158 + if port == "" {
159 + port = "80"
160 + }
161 }
162
163 // the underlying JSON does not yet support different