Allow direct IP access without reverse proxy
This commit is contained in:
@@ -2,7 +2,6 @@ package middleware
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -15,8 +14,10 @@ func DomainValidatorMiddleware(domain string) gin.HandlerFunc {
|
||||
host, _, _ = net.SplitHostPort(c.Request.Host)
|
||||
}
|
||||
|
||||
if host != domain {
|
||||
c.AbortWithStatus(http.StatusForbidden)
|
||||
// Allow direct IP access even when a domain is configured.
|
||||
// This keeps domain-based access working while removing the hard reverse-proxy-only restriction.
|
||||
if host != domain && net.ParseIP(host) == nil {
|
||||
c.AbortWithStatus(403)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user