mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-06-18 18:16:26 +00:00
Adds proxy host vars
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
"npm/internal/entity/certificate"
|
||||
"npm/internal/entity/host"
|
||||
"npm/internal/entity/nginxtemplate"
|
||||
"npm/internal/entity/upstream"
|
||||
)
|
||||
|
||||
// ValidateHost will check if associated objects exist and other checks
|
||||
@ -20,6 +21,21 @@ func ValidateHost(h host.Model) error {
|
||||
}
|
||||
}
|
||||
|
||||
if h.UpstreamID > 0 {
|
||||
// Check upstream exists
|
||||
if _, uErr := upstream.GetByID(h.UpstreamID); uErr != nil {
|
||||
return fmt.Errorf("Upstream #%d does not exist", h.UpstreamID)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure either UpstreamID is set or appropriate proxy host params are set
|
||||
if h.UpstreamID > 0 && (h.ProxyHost != "" || h.ProxyPort > 0) {
|
||||
return fmt.Errorf("Proxy Host or Port cannot be set when using an Upstream")
|
||||
}
|
||||
if h.UpstreamID == 0 && (h.ProxyHost == "" || h.ProxyPort < 1) {
|
||||
return fmt.Errorf("Proxy Host and Port must be specified, unless using an Upstream")
|
||||
}
|
||||
|
||||
// Check the nginx template exists and has the same type.
|
||||
nginxTemplate, tErr := nginxtemplate.GetByID(h.NginxTemplateID)
|
||||
if tErr != nil {
|
||||
|
Reference in New Issue
Block a user