mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 12:03:33 +00:00
chore: change reverse_proxy upstreams from 'to' to the directive arguments
This commit is contained in:
@@ -17,7 +17,6 @@ import (
|
|||||||
"github.com/psviderski/uncloud/pkg/api"
|
"github.com/psviderski/uncloud/pkg/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: change upstreams from 'to' to the directive arguments.
|
|
||||||
const caddyfileTemplate = `http:// {
|
const caddyfileTemplate = `http:// {
|
||||||
handle {{.VerifyPath}} {
|
handle {{.VerifyPath}} {
|
||||||
respond "{{.VerifyResponse}}" 200
|
respond "{{.VerifyResponse}}" 200
|
||||||
@@ -34,8 +33,7 @@ const caddyfileTemplate = `http:// {
|
|||||||
{{- range $hostname, $upstreams := .HTTPHostUpstreams}}
|
{{- range $hostname, $upstreams := .HTTPHostUpstreams}}
|
||||||
|
|
||||||
http://{{$hostname}} {
|
http://{{$hostname}} {
|
||||||
reverse_proxy {
|
reverse_proxy {{join $upstreams " "}} {
|
||||||
to {{join $upstreams " "}}
|
|
||||||
import common_proxy
|
import common_proxy
|
||||||
}
|
}
|
||||||
log
|
log
|
||||||
@@ -43,8 +41,7 @@ http://{{$hostname}} {
|
|||||||
{{- range $hostname, $upstreams := .HTTPSHostUpstreams}}
|
{{- range $hostname, $upstreams := .HTTPSHostUpstreams}}
|
||||||
|
|
||||||
https://{{$hostname}} {
|
https://{{$hostname}} {
|
||||||
reverse_proxy {
|
reverse_proxy {{join $upstreams " "}} {
|
||||||
to {{join $upstreams " "}}
|
|
||||||
import common_proxy
|
import common_proxy
|
||||||
}
|
}
|
||||||
log
|
log
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ func TestCaddyfileGenerator(t *testing.T) {
|
|||||||
},
|
},
|
||||||
want: caddyfileHeader + `
|
want: caddyfileHeader + `
|
||||||
http://app.example.com {
|
http://app.example.com {
|
||||||
reverse_proxy {
|
reverse_proxy 10.210.0.2:8080 {
|
||||||
to 10.210.0.2:8080
|
|
||||||
import common_proxy
|
import common_proxy
|
||||||
}
|
}
|
||||||
log
|
log
|
||||||
@@ -68,8 +67,7 @@ http://app.example.com {
|
|||||||
},
|
},
|
||||||
want: caddyfileHeader + `
|
want: caddyfileHeader + `
|
||||||
http://app.example.com {
|
http://app.example.com {
|
||||||
reverse_proxy {
|
reverse_proxy 10.210.0.2:8080 10.210.0.3:8080 {
|
||||||
to 10.210.0.2:8080 10.210.0.3:8080
|
|
||||||
import common_proxy
|
import common_proxy
|
||||||
}
|
}
|
||||||
log
|
log
|
||||||
@@ -83,8 +81,7 @@ http://app.example.com {
|
|||||||
},
|
},
|
||||||
want: caddyfileHeader + `
|
want: caddyfileHeader + `
|
||||||
https://secure.example.com {
|
https://secure.example.com {
|
||||||
reverse_proxy {
|
reverse_proxy 10.210.0.2:8000 {
|
||||||
to 10.210.0.2:8000
|
|
||||||
import common_proxy
|
import common_proxy
|
||||||
}
|
}
|
||||||
log
|
log
|
||||||
@@ -122,24 +119,21 @@ https://secure.example.com {
|
|||||||
},
|
},
|
||||||
want: caddyfileHeader + `
|
want: caddyfileHeader + `
|
||||||
http://app.example.com {
|
http://app.example.com {
|
||||||
reverse_proxy {
|
reverse_proxy 10.210.0.2:8080 10.210.0.3:8080 10.210.0.5:8080 {
|
||||||
to 10.210.0.2:8080 10.210.0.3:8080 10.210.0.5:8080
|
|
||||||
import common_proxy
|
import common_proxy
|
||||||
}
|
}
|
||||||
log
|
log
|
||||||
}
|
}
|
||||||
|
|
||||||
http://web.example.com {
|
http://web.example.com {
|
||||||
reverse_proxy {
|
reverse_proxy 10.210.0.2:8000 10.210.0.4:8000 10.210.0.5:8000 {
|
||||||
to 10.210.0.2:8000 10.210.0.4:8000 10.210.0.5:8000
|
|
||||||
import common_proxy
|
import common_proxy
|
||||||
}
|
}
|
||||||
log
|
log
|
||||||
}
|
}
|
||||||
|
|
||||||
https://secure.example.com {
|
https://secure.example.com {
|
||||||
reverse_proxy {
|
reverse_proxy 10.210.0.3:8888 10.210.0.4:8888 10.210.0.5:8888 {
|
||||||
to 10.210.0.3:8888 10.210.0.4:8888 10.210.0.5:8888
|
|
||||||
import common_proxy
|
import common_proxy
|
||||||
}
|
}
|
||||||
log
|
log
|
||||||
@@ -399,8 +393,7 @@ web.example.com {
|
|||||||
|
|
||||||
` + caddyfileBase + `
|
` + caddyfileBase + `
|
||||||
http://app.example.com {
|
http://app.example.com {
|
||||||
reverse_proxy {
|
reverse_proxy 10.210.0.2:8080 {
|
||||||
to 10.210.0.2:8080
|
|
||||||
import common_proxy
|
import common_proxy
|
||||||
}
|
}
|
||||||
log
|
log
|
||||||
@@ -433,8 +426,7 @@ api.example.com {
|
|||||||
},
|
},
|
||||||
want: caddyfileBase + `
|
want: caddyfileBase + `
|
||||||
http://api.example.com {
|
http://api.example.com {
|
||||||
reverse_proxy {
|
reverse_proxy 10.210.0.3:8080 {
|
||||||
to 10.210.0.3:8080
|
|
||||||
import common_proxy
|
import common_proxy
|
||||||
}
|
}
|
||||||
log
|
log
|
||||||
@@ -580,7 +572,7 @@ gateway.example.com {
|
|||||||
|
|
||||||
# Service with mixed containers (web) and advanced template
|
# Service with mixed containers (web) and advanced template
|
||||||
handle /web {
|
handle /web {
|
||||||
reverse_proxy {{- range $up := index .Upstreams "web"}} {{$up}}{{end}}
|
reverse_proxy {{- range $ip := index .Upstreams "web"}} https://{{$ip}}{{end}}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Non-existent service
|
# Non-existent service
|
||||||
@@ -620,24 +612,21 @@ localhost:8080 {
|
|||||||
|
|
||||||
` + caddyfileBase + `
|
` + caddyfileBase + `
|
||||||
http://api.example.com {
|
http://api.example.com {
|
||||||
reverse_proxy {
|
reverse_proxy 10.210.1.2:8080 10.210.2.2:8080 10.210.3.2:8080 {
|
||||||
to 10.210.1.2:8080 10.210.2.2:8080 10.210.3.2:8080
|
|
||||||
import common_proxy
|
import common_proxy
|
||||||
}
|
}
|
||||||
log
|
log
|
||||||
}
|
}
|
||||||
|
|
||||||
http://app.example.com {
|
http://app.example.com {
|
||||||
reverse_proxy {
|
reverse_proxy 10.210.1.6:3000 10.210.2.6:3000 {
|
||||||
to 10.210.1.6:3000 10.210.2.6:3000
|
|
||||||
import common_proxy
|
import common_proxy
|
||||||
}
|
}
|
||||||
log
|
log
|
||||||
}
|
}
|
||||||
|
|
||||||
http://web.example.com {
|
http://web.example.com {
|
||||||
reverse_proxy {
|
reverse_proxy 10.210.3.3:3000 {
|
||||||
to 10.210.3.3:3000
|
|
||||||
import common_proxy
|
import common_proxy
|
||||||
}
|
}
|
||||||
log
|
log
|
||||||
@@ -677,7 +666,7 @@ gateway.example.com {
|
|||||||
|
|
||||||
# Service with mixed containers (web) and advanced template
|
# Service with mixed containers (web) and advanced template
|
||||||
handle /web {
|
handle /web {
|
||||||
reverse_proxy 10.210.1.3 10.210.3.3 10.210.2.3
|
reverse_proxy https://10.210.1.3 https://10.210.3.3 https://10.210.2.3
|
||||||
}
|
}
|
||||||
|
|
||||||
# Non-existent service
|
# Non-existent service
|
||||||
|
|||||||
Reference in New Issue
Block a user