1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-16 21:56:40 -05:00

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
This commit is contained in:
Mohammed Al Sahaf 2020-10-01 22:53:19 +03:00 committed by GitHub
parent fdfdc03339
commit aa9c3eb732
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 116 additions and 0 deletions

View file

@ -0,0 +1,113 @@
whoami.example.com {
reverse_proxy whoami
}
app.example.com {
reverse_proxy app:80
}
unix.example.com {
reverse_proxy unix//path/to/socket
}
----------
{
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":443"
],
"routes": [
{
"match": [
{
"host": [
"whoami.example.com"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "whoami:80"
}
]
}
]
}
]
}
],
"terminal": true
},
{
"match": [
{
"host": [
"unix.example.com"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "unix//path/to/socket"
}
]
}
]
}
]
}
],
"terminal": true
},
{
"match": [
{
"host": [
"app.example.com"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "app:80"
}
]
}
]
}
]
}
],
"terminal": true
}
]
}
}
}
}
}

View file

@ -155,6 +155,9 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
if err != nil {
host = upstreamAddr
}
if port == "" {
port = "80"
}
}
// the underlying JSON does not yet support different