From 1a24c386ce3e7cb605db540a401ba83428fa1ece Mon Sep 17 00:00:00 2001 From: mhsanaei Date: Thu, 8 Aug 2024 10:52:59 +0200 Subject: [PATCH] Fix domain validation for Nginx/CDN compatibility #2450 --- web/middleware/domainValidator.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/web/middleware/domainValidator.go b/web/middleware/domainValidator.go index 52d2782c..3b7b592a 100644 --- a/web/middleware/domainValidator.go +++ b/web/middleware/domainValidator.go @@ -11,14 +11,12 @@ import ( func DomainValidatorMiddleware(domain string) gin.HandlerFunc { return func(c *gin.Context) { host := c.GetHeader("X-Forwarded-Host") - if host == "" { - host = c.GetHeader("X-Real-IP") - } if host == "" { host = c.Request.Host - if colonIndex := strings.LastIndex(host, ":"); colonIndex != -1 { - host, _, _ = net.SplitHostPort(host) - } + } + + if colonIndex := strings.LastIndex(host, ":"); colonIndex != -1 { + host, _, _ = net.SplitHostPort(host) } if host != domain {